创建不为空且不为空的 Elasticsearch curl 查询(“") [英] Create Elasticsearch curl query for not null and not empty("")
本文介绍了创建不为空且不为空的 Elasticsearch curl 查询(“")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建 Elasticsearch curl 查询以获取非空且非空的字段值("),
How can i create Elasticsearch curl query to get the field value which are not null and not empty(""),
这里是mysql查询:
Here is the mysql query:
select field1 from mytable where field1!=null and field1!="";
推荐答案
空值和空字符串都导致没有值被索引,在这种情况下你可以使用 exists
过滤器>
A null value and an empty string both result in no value being indexed, in which case you can use the exists
filter
curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"query" : {
"constant_score" : {
"filter" : {
"exists" : {
"field" : "myfield"
}
}
}
}
}
'
或结合(例如)title
字段上的全文搜索:
Or in combination with (eg) a full text search on the title
field:
curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"query" : {
"filtered" : {
"filter" : {
"exists" : {
"field" : "myfield"
}
},
"query" : {
"match" : {
"title" : "search keywords"
}
}
}
}
}
'
这篇关于创建不为空且不为空的 Elasticsearch curl 查询(“")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文