Reputation: 63
I have a query where using a wildcard on the filter returns results but using the actual text in the results to do a query returns 0 hits.
This works
{
"query": {
"filtered": {
"query": { "match_all": { } },
"filter": {
"nested": {
"path": "houses",
"query": {
"filtered": {
"query": { "match_all": { } },
"filter": {
"wildcard": {
"houses.name": "????"
}
}
}
}
}
}
}
}
}
If it returns a house named "Eve gardens", this returns nothing.
{
"query": {
"filtered": {
"query": { "match_all": { } },
"filter": {
"nested": {
"path": "houses",
"query": {
"filtered": {
"query": { "match_all": { } },
"filter": {
"wildcard": {
"houses.name": "Eve gardens"
}
}
}
}
}
}
}
}
}
Please help!
Upvotes: 0
Views: 716
Reputation: 7649
See this:
As per your query houses.name
seems to be an analyzed
string which means Eve gardens
would be tokenized and stored as eve
, gardens
not as Eve gardens
as a whole. As per documentation
The wildcard query operates on terms. If you use them to query an analyzed field, they will examine each term in the field, not the field as a whole.
So if you do
"wildcard": {"houses.name": "Eve gardens"}
this will not work.
Try
"wildcard": {"houses.name": "eve*"}
It should fetch you the results. Hope this helps..
Upvotes: 2