ruby - ElasticSearch with n word separation and regular expression (with Tire gem) -


i using elasticsearch (with tire gem). have following query match escaped cat, escaped black cat, etc.

i wondering, possible ask elasticsearch search following criteria:

  1. "escaped [exactly 0 or 1 word] cat" ie) escaped \w{0,1} cat
  2. "escaped [n words] cat" ie) escaped \w{n} cat
  3. "escaped [regular expression here] cat" ie) escaped (big|black|white) cat

current searching query:

{   "query": {     "bool": {       "should": [         {           "query_string": {             "query": "\"escaped ? cat\"",             "analyzer": "snowball"           }         },         {           "query_string": {             "query": "\"escaped ? cat\"",             "default_operator": "and"           }         },         {           "flt_field": {             "content": {               "like_text": "\"escaped ? cat\""             }           }         },         {           "mlt_field": {             "content": {               "like_text": "\"escaped ? cat\""             }           }         }       ]     }   } } 

i think it's possible using elasticsearch's regexp query.

{     "regexp":{         "name.first": "s.*y"     } } 

there's regexp filter


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -