Elasticsearch NEST client creating multi-field fields with completion


(Zaid Amir) #1

I am trying to create some completion suggesters on some of my fields. My
document class looks like this:

[ElasticType(Name = "rawfiles", IdProperty = "guid")]
public class RAW
{
[ElasticProperty(OmitNorms = true, Index = FieldIndexOption.NotAnalyzed, 

Type = FieldType.String, Store = true)]
public string guid { get; set; }

[ElasticProperty(OmitNorms = true, Index = FieldIndexOption.Analyzed, 

Type = FieldType.String, Store = true, IndexAnalyzer = "def_analyzer",
SearchAnalyzer = "def_analyzer_search", AddSortField = true)]
public string filename { get; set; }

[ElasticProperty(OmitNorms = true, Index = FieldIndexOption.Analyzed, 

Type = FieldType.String, Store = true, IndexAnalyzer = "def_analyzer",
SearchAnalyzer = "def_analyzer_search")]
public List tags { get { return new List(); } }
}

And here is how I am trying to create the completion fields

public bool CreateMapping(ElasticClient client, string indexName)
{
IIndicesResponse result = null;
try
{
result = client.Map(
c => c.Index(indexName)
.MapFromAttributes()
.AllField(f => f.Enabled(false))
.SourceField(s => s.Enabled())
.Properties(p => p
.Completion(s => s.Name(n => n.tags.Suffix(
"comp"))
.IndexAnalyzer("standard")
.SearchAnalyzer("standard")
.MaxInputLength(20)
.Payloads()
.PreservePositionIncrements()
.PreserveSeparators())
.Completion(s2 => s2.Name(n=>n.filename.Suffix(
"comp"))
.IndexAnalyzer("standard")
.SearchAnalyzer("standard")
.MaxInputLength(20)
.Payloads()
.PreservePositionIncrements()
.PreserveSeparators())
)
);
}
catch (Exception)
{

    }

    return result != null && result.Acknowledged;
}

My problem is that this is only creating a single completion field named
"comp". I was under the impression that this will create two completion
fields, one named filename.comp and the other named tags.comp.

I then tried the answer on this SO question
http://stackoverflow.com/questions/21433586/nest-suggestcompletion-usage-throws-is-not-a-completion-suggest-field-excepti
but this complicated the matter even worse as now my two fields were mapped
as a completion field only.

Just to be clear, I want to create a multi-field (field) that has a data,
sort and completion fileds. Much like the one in this example
https://developer.rackspace.com/blog/qbox/

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9ac2dd42-47d3-437d-a5cb-af405b4235a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2