Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to get results only stemming and synonyms data is available. want to remove if documents contain only exact match phrases.

Example:

Query: If I search loss

Result: I got 3 documents first document contains only loss and second document contains loss, waste and third document contains loss and losses So I want to remove one first documnet that only contains loss.

  body: {
      settings: {
          index: {
              "analysis":{
                    "analyzer":{
                            "my_analyzer": {
                                    "tokenizer": "standard",
                                    "filter": [
                                            "lowercase",
                                    ]
                            },
                            "my_stemmer": {
                                    "tokenizer": "standard",
                                    "filter": [
                                            "custom_english_stemmer"
                                    ]
                            },
                            "analyzer_synonym":{
                                    "tokenizer":"standard",
                                    "filter":[
                                          "lowercase", "synonym"
                                    ]
                            }
                   },
                    "filter":{
                            "synonym":{
                                    "type":"synonym_graph",
                                    "synonyms_path":"synonyms.txt",
                                    "updateable":true,
                                    "lenient": true
                            },
                            "custom_english_stemmer": {
                                    "type": "stemmer",
                                    "name": "english"
                            }
                    }
              }
           }
      mappings: {
          properties: {
              all_text: {
                  type: 'text',
                  search_analyzer: "analyzer_synonym",
                  analyzer: "my_analyzer",
                  fields: {
                    raw: { type:  'text'},
                    stemmer: {type:  'text', analyzer: "my_stemmer"}
                  }
              },
              #transcript: {
              #    type:'nested'
              #}
          }
      }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
254 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use the must_not clause of boolean query to achieve it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...