admin管理员组文章数量:1415491
I have some data indexed in an aws open search instance, which i understand is basically elastic search . the sample data below .
I verified i can do a search via sample search query below. How do i search for items , say that falls in category electronics .
GET _search
{
"query" : {
"match_all" : {}
}
}
sample data
{
"_index" : "my_index",
"_id" : "123abc",
"_score" : 1,
"_source" : {
"_id" : "123abc",
"vector" : [ 1, 2, 3 ....],
"category" : ["electronics", "stationary" ]
}
}
I have some data indexed in an aws open search instance, which i understand is basically elastic search . the sample data below .
I verified i can do a search via sample search query below. How do i search for items , say that falls in category electronics .
GET _search
{
"query" : {
"match_all" : {}
}
}
sample data
{
"_index" : "my_index",
"_id" : "123abc",
"_score" : 1,
"_source" : {
"_id" : "123abc",
"vector" : [ 1, 2, 3 ....],
"category" : ["electronics", "stationary" ]
}
}
Share
Improve this question
asked Feb 21 at 2:13
no_reservationsno_reservations
213 bronze badges
1 Answer
Reset to default 0GET /my_index/_search
{
"query": {
"term": {
"category": "electronics"
}
}
}
If you want to set an or
condition, you can use the should
syntax. If any of the conditions in the should
are met, the match will succeed.
GET /my_index/_search
{
"query": {
"bool": {
"should": [
{ "term": { "category": "electronics" } },
{ "term": { "category": "stationary" } }
],
"minimum_should_match": 1
}
}
}
本文标签: elasticsearchhow to query based on particular field in elasticopen searchStack Overflow
版权声明:本文标题:elasticsearch - how to query based on particular field in elasticopen search? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745170385a2645939.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论