"constant score query doesn't support query" error is coming when i am trying to run the following code.
client.search({
index: ['index1','index2'],
body: {
from: 0, size: 20,
query: {
"constant_score": {
boost: 1.0,
"query": {
query_string: {
query: str,
fields: ['field_1']
}
}
}
}
},
});
constant_score query wraps another query. It either accepts another query or filter . Wrap query_string in filter instead of query.
Try using the below:
client.search({
index: ['index1','index2'],
body: {
from: 0, size: 20,
query: {
"constant_score": {
boost: 1.0,
filter: {
query_string: {
query: str,
fields: ['field_1']
}
}
}
}
},
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With