Home > Back-end >  Consult elastic search query syntax
Consult elastic search query syntax

Time:09-29

The younger brother business similar to the following SQL: SQL
Select * from the customer where brandId=101237 and ` name ` like '% zhang SAN % and (levelId=347482700351079424 or ISNULL (levelId) limit 10;

Now write the script for:
{
"Query" : {
"Bool" : {
"Filter" : [
{
"Term" : {
"BrandId" : 101237
}
},
{
"Bool" : {
"Must_not" : {
"Term" : {
6 "loginType" :
}
}
}
},
{
"Term" : {
1
"bindFlag" :}
},
{
"Term" : {
"Status" : 0
}
}
],
"Must" : [
{
"Multi_match" : {
"Query" : "zhang",
"Fields" : [
"Name",
"Mobile"
],
"Operator" : "and"
}
},
{
"Bool" : {
"Should" :
{
"Terms" : {
"LevelId" : [
347482700351079424
]
}
},
{
"Bool" : {
"Must_not" : {
"Exists" : {
"Field" : "levelId"
}
}
}
}
]
}
}
]
}
},
"Size" : 200,
"Sort" : []
}
Problems:
Do not check the query result is not correct (data), the index is levelId=347482700351079424 or levelId data is empty, there is also a 'zhang' data were included in the name field.
Have studied a night didn't find a good solution, a great god help see many thanks:
  • Related