Elasticsearch boost

Hi,

I have a problem with elasticsearch boost. I use Node Js API, and my query looks something like this:

query: {
	bool: {
		should: [
			{ match: {
				"name":  {
					query: args.text,
					boost: 10
				}}
			},
			{ match: {
				"tags":  {
					query: args.text,
					boost: 8
				}}
			}
		]
	}
};

and consider I have these docs ( I actually have a lot of docs, and most of them has jumps in the name):

docs: [{name: "fox jumps", tag: "animal"}, {name: "monkey jumps" tag: "jumps"];

For some reason, if I search for: "fox brown jumps" I got this in the rank:

  1. monkey jumps
  2. fox jumps

In the explanation, it seems that when it gets "fox jumps" it matches "fox" (first match in name) and got a high score, but when it matches "jumps" (second match in name) it scores pretty low.

Meanwhile when it searches for "monkey jumps" it matches "jumps" (first match in name) and got a high score, and it matches "jumps" (first match in tags) it also got a high score.

Does anyone knows why that happens? I know that scoring is not just a sum of the boost, but I would assume that "fox jumps" should get score of 20 (or thereabouts) and "monkey jumps" should get a score of 18. Therefore, "fox jumps" should be ranked higher than "monkey jumps".

I can get around it by boosting the name a whole more, say I boost name to 100 and tags to 10. But I would like to get an explanation of how this should work if possible.

if you do not understand how scoring is happening, one of the best ways of debugging this is using either the explain API or the explain parameter in a search request.

This will show how each part of the score is calculated.

I did use the explain: true, that's how I can see that "jumps" which is the second match for "fox jumps", actually scored quite low..

I was hoping that there should be an easy explanation without having to look at the whole explanation tree (it is huge since I have a bunch of should match).

Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.