q参数的等效Query DSL对象是什么?

时间:2016-03-08 20:08:58

标签: elasticsearch

当我在弹性搜索上_search时,有时我只是使用像q=NEEDLE这样的字符串进行查询,让所有内容都自动生成,但是当我想要更复杂的查询时,我会使用

{
  query:{ ... }
}

对象。

我在想,

在Query DSL对象中发送查询字符串q=NEEDLE等同于什么?

1 个答案:

答案 0 :(得分:2)

相当于Query String。您可以通过code确认 对于OP "q=needle"中的情况,Query-String针对default_field运行。

根据文档,这默认为index.query.default_field索引设置,而索引设置默认为"_all"

示例:

{
    "query": {
        "query_string": {

           "query": "needle",
           "analyze_wildcard": false,
           "lenient" : false,
           "lowercase_expanded_terms" : true
        }
    }
}