mongodb - Predefined Term Mapping -


i have not yet used elasticsearch please excuse bad description. know if possible configure elasticsearch following - had issues in mongodb full text search functionalities seem little limiting.

here's problem - when search term korea not want match north korea or n. korea in document.

the assumption search korea south korea. different synonym kind of opposite. phrase search south korea out of question here isn't applicable in problem. possible?

i accept answers either mongodb or elasticsearch.

what if use query one:

{   "query": {     "bool": {       "should": [         {           "match": {             "some_field": "korea"           }         },         {           "query_string": {             "query": "-some_field:(\"north korea\")"           }         },         {           "query_string": {             "query": "-some_field:(\"n. korea\")"           }         }       ]     }   } } 

what this:

  • if field content matches "korea" it's receiving score
  • if field isn't matching "north korea" again it's getting score boost
  • again, if doesn't match "n. korea" getting additional score.

basically, score increases if matches "korea", if doesn't match "north korea" , if doesn't match "n. korea".

for example, documents this

post /my_index/test/1 {   "text": "north korea" } post /my_index/test/2 {   "text": "korea" } post /my_index/test/3 {   "text": "n. korea" } post /my_index/test/4 {   "text": "south korea" } 

the query above return this:

  "hits": [      {         "_index": "korea",         "_type": "test",         "_id": "2",         "_score": 1.4471208,         "_source": {            "text": "korea"         }      },      {         "_index": "korea",         "_type": "test",         "_id": "4",         "_score": 1.4227209,         "_source": {            "text": "south korea"         }      },      {         "_index": "korea",         "_type": "test",         "_id": "1",         "_score": 0.48779577,         "_source": {            "text": "north korea"         }      },      {         "_index": "korea",         "_type": "test",         "_id": "3",         "_score": 0.48779577,         "_source": {            "text": "n. korea"         }      }   ] 

the highest scores documents not north korea.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -