I have an sql table with columns Name, Category, Location. I am using Elastic Search with NEST. my query like this:
var result = client.Search<Models.Search.Poll>(s => s.Query(q => q.Fuzzy(f => f.OnField(p => p.Name).Value(query))))));
So if there is a record with name = "We are here" and user search "are" , it returns result.
Now I need to add two more parameters category and location to this query:
so I made it like this:
var result = client.Search<Models.Search.Poll>(s => s.Query(q => q.Fuzzy(f => f.OnField(p => p.Name).Value(query).OnField(r => r.Category).Value(category))));
but it is not working with query field now. but it works with category now. here is what I get when I type name but dont select category:
StatusCode: OK,
Method: POST,
Url: http://server.abc.com:9200/pollit-dev/polls/_search,
Request: {
"query": {
"fuzzy": {
"category": {
"value": "Select a Category"
}
}
}
},
Response: {"took":2892,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
I tried this one well:
var result = client.Search<Models.Search.Poll>(s => s.MatchAll().Query(q => q.Term(p => p.Name, query) || q.Term(p => p.Category,category) || q.Term(p => p.Location, Location)
but no luck so far.
Regards, Asif Hameed