I am trying to provide the search to end user with type as they go which is is more like sqlserver. I was able to implement ES query for the given sql scenario:
select * from table where name like '%pete%' and type != 'xyz and type!='abc'
But the ES query doesnt work for this sql query
select * from table where name like '%peter tom%' and type != 'xyz and type!='abc'
In my elastic search alongwith the wildcard query i also need to perform some boolean filtered query
{
"query": {
"filtered": {
"filter": {
"bool": {
"should": [
{
"query": {
"wildcard": {
"name": { "value": "*pete*" }
}
}
}
],
"must_not": [
{
"match": { "type": "xyz" }
},
{
"match": { "type": "abc" }
}
]
}
}
}
}
}
The above elastic query with wildcard search works fine and gets me all the documents that matches pete and are not of type xyz and abc .But when i try perform the wildcard with 2 seprate words seprated by space then the same query returns me empty as shown below.For example
{
"query": {
"filtered": {
"filter": {
"bool": {
"should": [
{
"query": {
"wildcard": {
"name": { "value": "*peter tom*" }
}
}
}
],
"must_not": [
{
"match": { "type": "xyz" }
},
{
"match": { "type": "abc" }
}
]
}
}
}
}
}
My mapping is as follows :
{
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
What query should i use in order to make wild card search possible for words seprated by spaces