Hello,
I am following the instructions here:
https://www.elastic.co/guide/en/elasticsearch/guide/current/bool-query.html
I'm using the Sense Chrome plugin with the following:
GET /my_index/_search
{
"query": {
"bool": {
"must": { "match": { "title": "quick" }},
"must_not": { "match": { "title": "lazy" }},
"should": [
{ "match": { "title": "brown" }},
{ "match": { "title": "dog" }}
]
}
}
}
As expected I am getting the 2 documents with scores (though the 2 scores area little different from what is in the doc provided by you guys.
The trouble I have is when using the Node API
My sample code is:
client.search({
index: "my_index",
"query": {
"bool": {
"must": { "match": { "title": "quick" }},
"must_not": { "match": { "title": "lazy" }},
"should": [
{ "match": { "title": "brown" }},
{ "match": { "title": "dog" }}
]
}
}
})
However, the results from my script are returning scores as 1 for all returned indexed items which is definitely incorrect.
I'm having a lot of trouble figuring out what is wrong with the code, and how to make it so that my code will return the right numbers, or at least not just all 1's for _score.
Example output:
[ { _index: 'my_index',
_type: 'my_type',
_id: '4',
_score: 1,
_source: { title: 'Brown fox brown dog' } },
{ _index: 'my_index',
_type: 'my_type',
_id: '1',
_score: 1,
_source: { title: 'The quick brown fox' } },
{ _index: 'my_index',
_type: 'my_type',
_id: '2',
_score: 1,
_source: { title: 'The quick brown fox jumps over the lazy dog' } },
{ _index: 'my_index',
_type: 'my_type',
_id: '3',
_score: 1,
_source: { title: 'The quick brown fox jumps over the quick dog' } } ]