首页 文章

来自URL搜索的Elasticsearch搜索主体

提问于
浏览
2

如果我在浏览器中直接搜索elasticsearch,例如:

http://localhost:9200/mydocs/_search?q=Awesome%20Search

搜索主体数据实际上是什么样的?它在做 multi_match 并包括所有字段吗?我试过写一个 multi_match 包括所有字段,我在浏览器中做到这一点得到了不同的结果 .

2 回答

  • 2

    ?q=.... 不是 multi_match 查询,这是URI query,它正在使用query_string query .

    所以你的搜索被“翻译”为:

    {
      "query": {
        "query_string": {
          "query": "Awesome Search"
        }
      }
    }
    
  • 0

    您需要将 multi_match 查询作为请求体传递

    curl -XGET 'http://localhost:9200/your_index/_search?pretty=true' -d '{"query":{"multi_match":{"query":"keyword","fields":["field1","field2"]}}}'
    

相关问题