I am using NEST with ElasticSearch and I am trying to perform a search by allowing users to enter search phrases in the search field. Everything works fine no matter when the user enters the search phrase they need to make sure that the field name matches the field name in Elastic search.
For example, one of my fields is called bookTitle. If they search below then it works
bookTitle: "A Tale of Two Cities"
If they search, as an example below, it does not work
booktitle: "The Tale of Two Cities" BookTitle: "The Tale of Two Cities"
The code I'm using to search is below. Anyone have any ideas on how I can fix this. I was hoping there was an ElasticSearch / NEST parameter that allows me to do this and not do something ugly with the search text, for example, find “BookTitle” and replace “bookTitle”.
public List<ElasticSearchRecord> Search(string searchterm) {
var results = _client.Search<ElasticSearchRecord>(s => s
.Query(q => q
.QueryString(qs => qs
.DefaultField("content")
.Query(searchterm)
)
));
return results.Documents.ToList();
}
Any help is greatly appreciated.
source
share