简体   繁体   English

用于PHP的Elasticsearch查询

[英]Elasticsearch Query for PHP

I am new to ElasticSearch, and I am trying to solve a query the best way possible. 我是ElasticSearch的新手,我正在尝试以最佳方式解决查询。 I'm using PHP so it would be helpful to get to view it in that format, but I am ok to see it in any ElasticSearch DSL. 我正在使用PHP,因此以这种格式查看它会很有帮助,但是我可以在任何ElasticSearch DSL中查看它。

The query I need basically has to match Any or All words in multiple fields, say for example [title, description] 我需要的查询基本上必须匹配多个字段中的任何或所有单词,例如[title,description]

But I also want to only include any documents that can be filtered by any true case (example if the Document has "either" field1 = true OR field2 = true) 但是我也只想包含可以用任何真实情况过滤的任何文档(例如,如果文档具有“两个” field1 = true或field2 = true)

So example I search for "Nike boots that are green" 因此,我搜索“绿色的耐克靴子”

So for I would like to see results that would have Nike boots and Green so I could just do 因此,我希望看到具有耐克靴子和绿色的结果,所以我可以

'query' => [
  'query_string' => [
    'fields' => [ 'title^6', 'description^3' ],
    'query' => 'Nike boots that are green'
  ],
],

And I get all content that has the best score. 我得到的所有内容得分最高。 What I really want to add to my results are basically "filters" or "should " that if the Document either has field 'access' == 1 OR field 'permission' == 5, how will I do that. 我真正想要添加到结果中的基本上是“过滤器”或“应该”,如果文档具有字段“ access” == 1或字段“ permission” == 5,我将如何做到这一点。 I know now that it needs to be a boolean. 我现在知道它必须是布尔值。

Is it possible to have both query and boolean query in the same search? 是否可以在同一搜索中同时具有查询和布尔查询?

the query_string query supports OR query_string查询支持OR

'query' => [
  'query_string' => [
    'query' => 'access:1 OR permission:5'
  ],
],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM