Mudanças entre as edições de "Exemplo de índice com sinônimo"

De Basef
Ir para: navegação, pesquisa
Linha 39: Linha 39:
  
 
Repare que "society" foi substituído por termos como "futeba", "futebol", "esporte" ..., tudo graças aos nossos sinônimos.
 
Repare que "society" foi substituído por termos como "futeba", "futebol", "esporte" ..., tudo graças aos nossos sinônimos.
 +
 +
Outro exemplo:
 +
 +
<source lang="javascript">
 +
PUT /indice_com_sinonimo_2
 +
{
 +
  "settings": {
 +
    "index": {
 +
      "number_of_shards": 3,
 +
      "number_of_replicas": 0
 +
    },
 +
    "analysis": {
 +
      "filter": {
 +
        "filtro_de_sinonimos": {
 +
            "type": "synonym",
 +
            "synonyms": [
 +
                "futebol => futebol,society",
 +
                "society => society,futebol",
 +
                "esporte => esporte,futebol,society,volei,basquete"
 +
            ]
 +
        }
 +
      },
 +
      "analyzer": {
 +
        "sinonimos": {
 +
          "tokenizer":  "standard",
 +
          "filter": [
 +
            "lowercase",
 +
            "filtro_de_sinonimos"
 +
          ]
 +
        }
 +
      }
 +
    }
 +
  }
 +
}
 +
</source>
 +
  
 
[[Category: Elastic Search]]
 
[[Category: Elastic Search]]

Edição das 10h01min de 31 de julho de 2017

Segue abaixo exemplo de criação de índice com sinônimo:

PUT /indice_com_sinonimo
{
  "settings": {
    "index": {
      "number_of_shards": 3,
      "number_of_replicas": 0
    },
    "analysis": {
      "filter": {
        "filtro_de_sinonimos": {
            "type": "synonym",
            "synonyms": [
                "esporte,futebol,society,futeba,pelada"
            ]
        }
      },
      "analyzer": {
        "sinonimos": {
          "tokenizer":  "standard",
          "filter": [
            "lowercase",
            "filtro_de_sinonimos"
          ]
        }
      }
    }
  }
}

O seguinte request pode ser feito para analisar a substituição de sinônimos:

GET /indice_com_sinonimo/_analyze?analyzer=sinonimos&text=eu+gosto+de+jogar+society

Repare que "society" foi substituído por termos como "futeba", "futebol", "esporte" ..., tudo graças aos nossos sinônimos.

Outro exemplo:

PUT /indice_com_sinonimo_2
{
  "settings": {
    "index": {
      "number_of_shards": 3,
      "number_of_replicas": 0
    },
    "analysis": {
      "filter": {
        "filtro_de_sinonimos": {
            "type": "synonym",
            "synonyms": [
                "futebol => futebol,society",
                "society => society,futebol",
                "esporte => esporte,futebol,society,volei,basquete"
            ]
        }
      },
      "analyzer": {
        "sinonimos": {
          "tokenizer":  "standard",
          "filter": [
            "lowercase",
            "filtro_de_sinonimos"
          ]
        }
      }
    }
  }
}