user3532803
user3532803

Reputation:

how to avoid common tern in elasticsearch

I am using NEST(c#) client to play with elasticsearch in which when i search question like "how to find a " it will provide the result which contain max-hits for words like to and a . how can avoid search words like a , to, is , are, was etc. this is my code sample

var Result = client.Search(q => q
               .Index(IndexName)
               .From(0)
               .Type("table")
               .Size(10)
               .Fields("title","description")
               .QueryString(searchWord))

Upvotes: 0

Views: 346

Answers (1)

user3540491
user3540491

Reputation:

In NEST version 1.0 they implemented this.
You can do it by adding this line to your search I guess.

.Query(b => b.CommonTerms(c => c.CutOffFrequency(0.1)))

I have not been able to test this but I hope it helps.
More info can be found here: (elasticsearch 1.0)
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html#query-dsl-common-terms-query

and here: (release nodes NEST 1.0)

http://www.elasticsearch.org/blog/introducing-elasticsearch-net-nest-1-0-0-beta1/

Upvotes: 1

Related Questions