您使用什么URL来执行索引查询?
我在这里看到以下内容,但是这样做的URL是什么? http://www.elasticsearch.org/guide/reference/query-dsl/indices-query.html
我知道如何在弹性搜索中查询的唯一方法是使用URI:
http://localhost:9200/myindex
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我有多个索引与不同的文件myindex1 myindex2 myindex3
我希望能够对myindex1和myindex2(或者只是myindex2和myindex3)执行任何查询
这可能吗?您还可以将索引查询与QueryDSL结合使用,例如match_all查询或术语查询:
http://www.elasticsearch.org/guide/reference/query-dsl/terms-query.html
请显示一个示例URL的示例,如果可能的话,请求正文中包含的内容,以便我可以了解.
dad*_*net 16
你可以尝试:
curl http://localhost:9200/myindex1,myindex2/_search?q=*
Run Code Online (Sandbox Code Playgroud)
要么
curl -XPOST http://localhost:9200/myindex1,myindex2/_search -d '{
// your query here
}'
Run Code Online (Sandbox Code Playgroud)
这是你在找什么?
小智 7
如果你正在使用sense插件,你可以像这样写
POST myindex1/_search
{
"query": {"match_all": {}}
}
Run Code Online (Sandbox Code Playgroud)
小智 6
你可以用几种不同的方式做到这一点.
1)使用索引查询myindex1
并myindex2
在title
字段上使用术语查询.
curl -XPOST http://localhost:9200/_search -d '{
"query": {
"indices": {
"indices": [
"myindex1",
"myindex2"
],
"query": {
"terms": {
"title": [
"foo",
"bar"
]
}
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
2)通过指定要在URI中搜索的索引(具有相同的精确术语查询).
curl -XPOST http://localhost:9200/myindex1,myindex2/_search -d '{
"query": {
"terms": {
"title": [
"cookies",
"cake"
]
}
}
}'
Run Code Online (Sandbox Code Playgroud)
是的,您可以在两个示例中的任何一个中替换match_all查询(或此处的任何其他查询)的术语查询.以下是在第二个示例中执行match_all查询的方法:
curl -XPOST http://localhost:9200/myindex1,myindex2/_search -d '{
"query": {
"match_all": {}
}
}'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19363 次 |
最近记录: |