Good day,
I was busy with NEST on elasticsearch, but I have alot of troubling making it work.
I have this code for creating the index
var typeName = typeof(SEARCHTYPE).Name.ToLower();
var client = new ElasticClient(Settings);
client.DeleteIndex(typeName,x=>x.Index(typeName));
var ax = client.CreateIndex(typeName, c => c
.Index(typeName)
.Mappings(m => m.Map<SEARCHTYPE>(d => d.AutoMap())));
}
and my search is one string with multiple words which should get the best result based on this type. the type has the following fields
title: string
text:string
keywords:string(commaseparated)
identifiers:string(commaseparated)
I want the best result for my search
the priority is as follows:keywords,title identifiers,text
var searches = searchString.Split(' ').Where(x => x.Length > 2);
var searchItems = new List<string>();
var synonyms = new List<string>(); //todo
searchItems.Add(searchString);
foreach (var searchItem in searches)
{
searchItems.Add(searchItem);
searchItems.AddRange(languageItems.Where(x => x.StartsWith(searchItem)));
}
if (!searchItems.Any()) return new ReadOnlyCollection<SearchSuggestion>(new List<SearchSuggestion>());
//Okay, I admit... I need help
var search=Client.Search<SearchSuggestion>(x => x
.Query(q => q
.Terms(b =>b
.Terms(searchItems).Boost(1.6)))
);
return search.Documents;
}
Could anybody please help me?
I am having alot of troubles with this...
thank you in advance.
Yureh