Closed iluvcode closed 9 years ago
Hi,
I am working on SuggestCompletion. After indexing all the records, when i execute a query i get below error message.
"Failed to execute phase [query], all shards failed; shardFailures {[TaTSmiM2TV27_ptdFdx5eQ][elasticsearchlocal][0]: SearchParseException[[elasticsearchlocal][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\r\n \"suggest\": {\r\n \"mysuggest\": {\r\n \"text\": \"pota\",\r\n \"completion\": {\r\n \"field\": \"shortDescription\",\r\n \"size\": 20\r\n }\r\n }\r\n }\r\n}]]]; nested: ClassCastException[org.elasticsearch.index.mapper.core.StringFieldMapper cannot be cast to org.elasticsearch.index.mapper.core.CompletionFieldMapper]; }{[TaTSmiM2TV27_ptdFdx5eQ][elasticsearchlocal][1]: SearchParseException[[elasticsearchlocal][1]: from[-1],size[-1]: Parse Failure}"
This is how my code looks
Public Class AutoComplete { public int ItemId { get; set; }
public SuggestionField ShortDescription { get; set; } public string BrandName { get; set; } public string[] MenuNode { get; set; } public decimal Weight { get; set;
}
public class SuggestionField { public string[] Input { get; set; }
public string Output { get; set; } }
Indexing Query public static bool CreateIndex() { var result = ElasticClientSingleton.WriteInstance.CreateIndex(IndexName, index => index .AddMapping(tmd => tmd .Properties(props => props .Completion(s => s.Name(p => p.ShortDescription) .IndexAnalyzer("stop") .SearchAnalyzer("stop") .MaxInputLength(20) .Payloads(true) .PreservePositionIncrements() .PreserveSeparators() ) .Completion(s => s.Name(p => p.BrandName) .IndexAnalyzer("stop") .SearchAnalyzer("stop") .MaxInputLength(20) .Payloads(true) .PreservePositionIncrements() .PreserveSeparators()) .Completion(s => s.Name(p => p.MenuNode) .IndexAnalyzer("stop") .SearchAnalyzer("stop") .MaxInputLength(20) .Payloads(true) .PreservePositionIncrements() .PreserveSeparators()) ) ) );
return result.IsValid; }
Query: var query = ElasticClientSingleton.ReadInstance.Search(s => s .Index(IndexName) .SuggestCompletion("mysuggest", ts => ts .Text(searchTerm) .OnField(p => p.ShortDescription) .Size(20) ));
Hi @iluvcode
Please ask questions like these on the mailing list, rather than here. The issues list is for bug reports and feature requests
thanks
Hi,
I am working on SuggestCompletion. After indexing all the records, when i execute a query i get below error message.
"Failed to execute phase [query], all shards failed; shardFailures {[TaTSmiM2TV27_ptdFdx5eQ][elasticsearchlocal][0]: SearchParseException[[elasticsearchlocal][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\r\n \"suggest\": {\r\n \"mysuggest\": {\r\n \"text\": \"pota\",\r\n \"completion\": {\r\n \"field\": \"shortDescription\",\r\n \"size\": 20\r\n }\r\n }\r\n }\r\n}]]]; nested: ClassCastException[org.elasticsearch.index.mapper.core.StringFieldMapper cannot be cast to org.elasticsearch.index.mapper.core.CompletionFieldMapper]; }{[TaTSmiM2TV27_ptdFdx5eQ][elasticsearchlocal][1]: SearchParseException[[elasticsearchlocal][1]: from[-1],size[-1]: Parse Failure}"
This is how my code looks
Public Class AutoComplete { public int ItemId { get; set; }
}
public class SuggestionField { public string[] Input { get; set; }
Indexing Query(tmd => tmd
.Properties(props => props
.Completion(s =>
s.Name(p => p.ShortDescription)
.IndexAnalyzer("stop")
.SearchAnalyzer("stop")
.MaxInputLength(20)
.Payloads(true)
.PreservePositionIncrements()
.PreserveSeparators()
)
.Completion(s =>
s.Name(p => p.BrandName)
.IndexAnalyzer("stop")
.SearchAnalyzer("stop")
.MaxInputLength(20)
.Payloads(true)
.PreservePositionIncrements()
.PreserveSeparators())
.Completion(s =>
s.Name(p => p.MenuNode)
.IndexAnalyzer("stop")
.SearchAnalyzer("stop")
.MaxInputLength(20)
.Payloads(true)
.PreservePositionIncrements()
.PreserveSeparators())
)
)
);
public static bool CreateIndex() { var result = ElasticClientSingleton.WriteInstance.CreateIndex(IndexName, index => index .AddMapping
Query: var query = ElasticClientSingleton.ReadInstance.Search(s => s
.Index(IndexName)
.SuggestCompletion("mysuggest", ts => ts
.Text(searchTerm)
.OnField(p => p.ShortDescription)
.Size(20)
));