I have some code which should return 5 matches from the search.
If I try the query in browser, I get 5 results:
http://localhost:9200/_search?q=Testing
If I user SENSE editor it also shows my 5 results:
Server=localhost:9200
POST _search
{
"query": {
"query_string": {
"query": "Testing"
}
}
}
But my C# code in controller fails to get any match. What am I missing?
Uri localhost = new Uri("http://localhost:9200");
var setting = new ConnectionSettings(localhost);
setting.SetDefaultIndex("videos");
var client = new ElasticClient(setting);
var result = client.Search<SearchHint>(
body => body.Query(
query => query.QueryString(
qs => qs.Query(keys))));
var results = new SearchResults()
{
Results = result.Documents.ToList() <-- this has 0 items
};
EDIT 1:
public class SearchHint
{
public string Id { get; set; }
public string Title { get; set; }
public int NumItems { get; set; }
public bool IsList { get; set; }
public SearchHint(string id, string title, int numItems, bool isList)
{
Id = id;
Title = title;
NumItems = numItems;
IsList = isList;
}
}
EDIT 2: There are 4 types in the index (videos\list, videos\video, videos\author, videos\category). Any search should search all types not any particular type.