Hello, Im' writing to you because I have a problem and I can't find the answer myself.
I'm indexing documents, with nested paragraphs.
Ex : {
"title": "how to recyle"
"paragraph" : [
"title": "about iron",
"warning": "badWords"
]
}
It's just an exemple.
Let's imagine that I want to search for "recycle iron". I would like my document to match, but I don't want the paragraph to show up because it contains "badWords"... Is it possible.
My problem is that, if I exclude paragraphs with "badWords", the document doesn't match at all.
Here is my query (I know, the query is too big, but it's part of a bigger query)
This query make sur that both words are present, in the title OR the text.
The best, for me would be to exclude, the uis, but only when I display the result. I still want the document to match. Is it possible? With some kind of post_filter?
{
"query": {
"bool": {
"must": [
{
"bool": {
"minimum_should_match": "2<80%",
"should": [
{
"bool": {
"should": [
{
"multi_match": {
"query": "recycle",
"fields": [
"title"
],
"type": "phrase",
"boost": 1
}
},
{
"nested": {
"path": "paragraph",
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "recycle",
"fields": [
"paragraph.text"
],
"type": "phrase",
"boost": 1
}
}
]
}
},
"inner_hits": {
"size": 100
}
}
}
]
}
},
{
"bool": {
"should": [
{
"multi_match": {
"query": "iron",
"fields": [
"title"
],
"type": "phrase",
"boost": 1
}
},
{
"nested": {
"path": "paragraph",
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "iron",
"fields": [
"paragraph.text"
],
"type": "phrase",
"boost": 1
}
}
]
}
},
"inner_hits": {
"size": 100
}
}
}
]
}
}
]
}
}
]
}
},
"from": 0,
"size": 10
}