[英]Elastic-search & Nest query
how can i query all the records that contains a specific string? 我如何查询包含特定字符串的所有记录?
for example: 例如:
if those at the db 如果那些在数据库
{
"ip": "185.239.131.76",
"domain": "http://express.com",
"event_type": "page_view"
},
{
"ip": "185.239.131.76",
"domain": "http://express.com",
"event_type": "page_view"
},
{
"ip": "37.39.244.71",
"domain": "http://express.com",
"event_type": "view"
},
and i want to fetch all records that contains the string "page" 我想获取包含字符串“ page”的所有记录
so i get the only the first 2 of the 3 records above? 所以我只获得上面3条记录中的前2条?
can show the http query and the nest query also? 可以显示http查询和nest查询吗?
thanks 谢谢
You can try a post query : 您可以尝试发布查询:
http://localhost:9200/YourIndex/_search?=pretty=true http:// localhost:9200 / YourIndex / _search?= pretty = true
Query : 查询:
{
"query": {
"match": {
"event_type": "page_view"
}
}
If I understood your problem correctly, you have a field event_type
which has values like page_view
and view
and maybe page_action
, values are single strings though. 如果我正确理解了您的问题,则您有一个event_type
字段,该字段具有诸如page_view
和view
值,也许还有page_action
,但这些值都是单个字符串。
My approach to query for page
in event_type
would be to map event_type
as not_analyzed
like below mapping
我在event_type
查询page
方法是将event_type
mapping
为not_analyzed
,如下mapping
"event_type": {
"index": "not_analyzed",
"type": "string"
},
And then query for strings starting with page
like 然后查询像这样的page
开头的字符串
GET yourIndex/_search
{ "query": {
"prefix": {
"event_type": {
"value": "page"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.