Java 在我的Elasticsearch查询中放置逗号的位置
我正在为我的Laravel应用程序使用此ES软件包 但我不确定应该在查询字符串中的什么位置放置逗号。我明白,如果内部数组中有多个元素,则必须使用逗号。但是所有数组都需要逗号吗。这两个问题似乎都很有效,这就是我想知道的原因。我想把它做得最好,这就是我为什么要问的原因Java 在我的Elasticsearch查询中放置逗号的位置,java,php,mysql,laravel,
elasticsearch,Java,Php,Mysql,Laravel,
elasticsearch,我正在为我的Laravel应用程序使用此ES软件包 但我不确定应该在查询字符串中的什么位置放置逗号。我明白,如果内部数组中有多个元素,则必须使用逗号。但是所有数组都需要逗号吗。这两个问题似乎都很有效,这就是我想知道的原因。我想把它做得最好,这就是我为什么要问的原因 'filtered' => [ 'query' => [ 'match' => ['title' => Input::get('query
'filtered' => [
'query' => [
'match' => ['title' => Input::get('query')]
],
'filter'=> [
'bool' => [
'must' => [
['term' => [ 'type' => 1] ],
['term' => [ 'state' => 22] ],
['term' => [ 'city' => ] ],
[ 'range' => [
'price' => [
'gte' => ,
'lte' => ,
]
]
]
]
]
],
],
还有更多的逗号符号(,)
他们两个似乎都工作。下面是使用此包的完整查询示例:
$posts = Post::searchByQuery([
'filtered' => [
'filter' => [
'not' => [
'terms' => ['title' => ['impedit', 'voluptatem']]
]
],
'query' => [
"bool" => [
'must' => [
'multi_match' => [
'query' => Input::get('query', ''),
'fields' => [ "title^2", "content"]
],
],
"should" => [
'match' => [
'tags' => [
"query" => Input::get('query', ''),
"type" => "phrase"
]
]
]
]
],
],
]);
此外,是否可以像我在查询#1和#2中那样在MUST中使用3个过滤器,或者在第二个版本的查询中,您只能在should{}中放置多个过滤器,放置尾随逗号通常用于指示其他参数。由于您只有一组参数,因此不需要额外的逗号。例如,在
filter=>
块后加逗号表示filter后面还有其他语句。另外,为什么要为解析器留下额外的字符
'filtered' => [
'query' => [
'match' => ['title' => Input::get('query')]
],
'filter'=> [
'bool' => [
'must' => [
['term' => [ 'type' => 1] ],
['term' => [ 'state' => 22] ],
['term' => [ 'city' => ] ],
[ 'range' => [
'price' => [
'gte' => ,
'lte' => ,
]
]
]
], // <=== Other operators to filter on?
], // <=== Other operations other than query and filter?
],
],
“过滤的”=>[
“查询”=>[
'match'=>['title'=>Input::get('query')]
],
“过滤器”=>[
‘bool’=>[
“必须”=>[
['term'=>['type'=>1]],
['term'=>['state'=>22]],
['term'=>['city'=>]],
[“范围”=>[
“价格”=>[
“gte”=>,
“lte”=>,
]
]
]
], // [
“查询”=>[
'match'=>['title'=>Input::get('query')]
],
“过滤器”=>[
‘bool’=>[
“必须”=>[
['term'=>['type'=>1]],
['term'=>['state'=>22]],
['term'=>['city'=>]],
[“范围”=>[
“价格”=>[
“gte”=>,
“lte”=>,
]
]
]
],
“不得”=>[
['term'=>['state'=>23]]//但是你能像上面的例子那样有多个“必须”过滤器吗?我想我只能在should中使用多个,这是JSON,但是看看文档:{“过滤”:{“查询”:{“匹配”:{“tweet”:“全文搜索”}},“过滤”:{“bool”:{“必须”:{“范围”:{“创建”:{“gte”:“现在-1d/d”}}}},应该“{”术语“:{”特色“:真的},{”术语“:{”星号“:真的},”,“不得“:{”术语“:{”删除“:假的}}
'filtered' => [
'query' => [
'match' => ['title' => Input::get('query')]
],
'filter'=> [
'bool' => [
'must' => [
['term' => [ 'type' => 1] ],
['term' => [ 'state' => 22] ],
['term' => [ 'city' => ] ],
[ 'range' => [
'price' => [
'gte' => ,
'lte' => ,
]
]
]
], // <=== Other operators to filter on?
], // <=== Other operations other than query and filter?
],
],
filtered' => [
'query' => [
'match' => ['title' => Input::get('query')]
],
'filter'=> [
'bool' => [
'must' => [
['term' => [ 'type' => 1] ],
['term' => [ 'state' => 22] ],
['term' => [ 'city' => ] ],
[ 'range' => [
'price' => [
'gte' => ,
'lte' => ,
]
]
]
],
'must_not' => [
['term' => ['state' => 23] ] // <=== Additional must clause
]
]
],
],