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:
- "escaped [exactly 0 or 1 word] cat" ie)
escaped \w{0,1} cat - "escaped [n words] cat" ie)
escaped \w{n} cat - "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
Post a Comment