elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.57k stars 24.62k forks source link

SuggestCompletion , Failed to Execute Phase query : SearchPraseException issue #10737

Closed iluvcode closed 9 years ago

iluvcode commented 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)
));

clintongormley commented 9 years ago

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