ElasticSearch matching no more than query terms -


for search "w1 w2 w3" want retrieve documents contain of query terms no more. documents containing "w1", "w2", "w3", "w1 w2", "w1 w3", "w2 w3" or "w1 w2 w3" ok, not document containing "w1 w2 w3 w4". did programming elasticsearch => idea please?

use query string query: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

{     "query_string": {       "query": "(w1 or w2 or w3 or (w1 , w2) or (w1 , w3) or (w2 , w3)                  or (w1 , w2 , w3))"     } } 

or

{     "query_string": {       "query": "(w1 or w2 or w3) , not w4)"     } } 

or using bool query: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

{     "bool": {         "should":   { "match": "w1 w2 w3" },         "must_not": { "match": "w4" }     } } 

keeping having fun es;-)

ok, after comment better understand want do. use query string query regular expressions: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_regular_expressions

{   "query_string":{     "query":"/(w1|w2|w3|)(w1|w2|w3|)(w1|w2|w3)(w1|w2|w3|)(w1|w2|w3|)/"   } } 

this 1 match w1,w1,w1,w1,w1 too, have play bit around it. hope idea enough can contintue. have create regexp matches needs, idea short thought:-)


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -