I’m struggling to get a simple post filter to work:
My non filtered query has a few results:
{
"size": 2,
"query": {
"knn": {
"embedding": {
"k": 3, "vector": [...]
}
}
}
}
{
"hits": {
"total": {
"value": 634,
"relation": "eq"
},
"max_score": 0.7958787,
"hits": [
{
"_id": "8e4ca013a2b0c0ee1ee5b111c54857e1c9f222a59fe1c450a8e012c72ecbecfd",
"_score": 0.7958787,
"_source": {
"id_embedding": "8e4ca013a2b0c0ee1ee5b111c54857e1c9f222a59fe1c450a8e012c72ecbecfd",
"embedding": [...],
"content": """bla bla bla""",
"metadata": """{"location": "/introduction/index.html" ...}"""
}
}
]
}
}
I now add a post_filter
like so:
{
"size": 2,
"query": {
"knn": {
"embedding": {
"k": 3, "vector": [...]
}
}
},
"post_filter": {
"wildcard": { "metadata": "*html*" }
}
}
and this seem to remove all results, while as seen above some results should match.
{
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
}
}
I tried several ways to write this filter (match
, { "bool": { "must": [ ... ] } }
but could never get a result with a post filter.