简体   繁体   中英

Elasticsearch Query for PHP

I am new to ElasticSearch, and I am trying to solve a query the best way possible. 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.

The query I need basically has to match Any or All words in multiple fields, say for example [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)

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. 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' => [
  'query_string' => [
    'query' => 'access:1 OR permission:5'
  ],
],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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