My question is how can I use search options like multimatch, slop and fuzziness in a percolate function using NEST (c#)?
I want to implement a percolate function that returns exactly the opposite result of the following search function:
public List<string> search(string query){
.......
.......
var searchResponse = client.Search<Document>(s => s
.AllTypes()
.From(0)
.Take(10)
.Query(q => q // define query
.MultiMatch(mp => mp // of type MultiMatch
.Query(input.Trim())
.Fields(f => f // define fields to search against
.Fields(f3 => f3.doc_text))
.Slop(2)
.Operator(Operator.And)
.Fuzziness(Fuzziness.Auto))));
}
The following is the percolate function I currently use but don't know how to include multimatch, slop and fuzziness options. I could not find detail about this in its documentation.
var searchResponseDoc = client.Search<PercolatedQuery>(s => s
.Query(q => q
.Percolate(f => f
.Field(p => p.Query)
.DocumentType<Document>() //I have a class called Document
.Document(myDocument))) // myDocument is an object of type Document
Thanks.
In the first you are doing a
multi_matchquery which has the options you require. In the latter you do apercolatorquery.If you want to do both you can use binary and bitwise operators e.g
Not the use of
&&to create aboolquery with the two queries asmustclauses. The unary!operator negates the query by wrapping the query in abooland placing the query in amust_notclause.See more info https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/writing-queries.html
and
https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/bool-queries.html