In my code today I am doing a search like this:
.Query(q => q.QueryString(qs => qs.Query(searchQuery).OnFieldsWithBoost(f => f.Add(b => b.MetaTitle, 5).Add(b => b.RawText, 1))))
My problem is this gives me a very wide search if I search on a phrase like. "The sun is shining". I have tried using MatchPhrase on RawText, instead of QueryString, and that kinda works.
The problem is I still want to search in both MetaTitle and RawText and with the boosting I am using now.
I don't know Nest, but what you want to do is to use a multi-match query of phrase type, with fields boost.
A quick search on g**gle gave me a syntax like this for the boost part:
The API must have some sort of
type
parameter to add thephrase
type to this.Edit: after a quick look in the sources, I found a Type method, added above.
Since I have not found an example of a multimatch query search without defining a given type. I spent a few days trying to work it out and i came up with the solution.
I´m using NEST Library in C#. Here I leave the same method as above but using Generics, and passing a dictionary with the fields and boosts, since you will not have the intellisence writing with the fluent expression. I also added the skip and take (or from and size) methods, the Type of Search and an array of the indexes you want to perform the search.