简体   繁体   English

Elasticsearch查询字符串中的空值

[英]Empty values in Elasticsearch query string

I am using ES for my Laravel app in order to search a table/type. 我正在使用ES作为我的Laravel应用程序来搜索表格/类型。

My users can search a total of 5 columns which means that there can be a total of 31 query combinations. 我的用户可以搜索总共5列,这意味着总共可以有31个查询组合。

So my question is now if I can use the same query but dont provide ES with all the seach params. 所以我现在的问题是,如果我可以使用相同的查询但不提供ES所有的seach参数。 Or somehow write dynamic queries. 或以某种方式编写动态查询。

Eg: 例如:

'filtered' => [
  'query' => [
    'match' => ['title' => Input::get('query')]
   ],
   'filter'=> [
     'bool' => [
       'must' => [
         ['term' => [ 'type' => 1] ],
         ['term' => [ 'state' => 22] ],
         ['term' => [ 'city' => ] ], (empty)
         [
           'range' => [
             'price' => [
                'gte' => , (empty)
                'lte' => , (empty)
             ]
           ]
         ]
       ]
     ]
  ],
],

Otherwise I have to write 31 different combinations of this query - If ES dont have anything that can help me. 否则我必须写出这个查询的31种不同组合 - 如果ES没有任何可以帮助我的东西。 And I can use Laravels eloquent ORM for this. 我可以使用Laravels雄辩的ORM。

Thanks in advance 提前致谢

You can use Elasticquent 你可以使用Elasticquent

Elasticquent makes working with Elasticsearch and Eloquent models easier by mapping them to Elasticsearch types. Elasticquent通过将它们映射到Elasticsearch类型,使得更容易使用Elasticsearch和Eloquent模型。 You can use the default settings or define how Elasticsearch should index and search your Eloquent models right in the model. 您可以使用默认设置或定义Elasticsearch如何在模型中索引和搜索您的Eloquent模型。

Elasticquent uses the official Elasticsearch PHP API. Elasticquent使用官方的Elasticsearch PHP API。 To get started, you should have a basic knowledge of how Elasticsearch works (indexes, types, mappings, etc). 首先,您应该具备Elasticsearch如何工作的基本知识(索引,类型,映射等)。

https://github.com/adamfairholm/Elasticquent https://github.com/adamfairholm/Elasticquent

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

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