Elasticsearch reverse match_phrase

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

Consider following document:

{   "Title": "Western Europe" } 

I'd like to run such search queries against Title field

  • Apple in Western Europe
  • Apple in Eastern Europe

I could run a simple match query:

POST /_search {   "query": {     "match": {       "Title": "Apple in Western Europe"     }   } } 

It obiviously would match and bring it back irregardless of which search phrase I'd use. But I'd like to make a query that would bring my document back only if Title field phrase matches my search query. Is that possible? Are there any additional parameters? It seems like a reverse case for phrase matching.

If not, should I consider reindexing my data with shingles?

So in this scenario running this (with additional parameters) wouldn't score and bring back my document.

POST /_search {   "query": {     "match": {       "Title": "Apple in Eastern Europe"     }   } } 

tl;dr

How do I write a query that would bring back document if all of its field (the one I'm searching on) tokens are present in my search query? For instance my field in document contains these two tokens only:

  • abc
  • xyz

And if my search phrase is, for instance Lorem ipsum dolor sit amet, consectetur adipiscing elit abc xyz, document is brought back.

If it's Lorem ipsum dolor sit amet, consectetur adipiscing elit xyz, it's not brought back.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!