My autocomplete implementation of autocomplete worked in v2.3. But ever since the upgrade, I can't figure out how to apply index and search time analyzers to the attachment's content field for all ingested attachments like PDFs and so forth. Does anyone have an example or a pointer to getting me started? Thank you so much in advance!
I have followed the example listed under "The Future" in https://www.elastic.co/blog/the-future-of-attachments-for-elasticsearch-and-dotnet, and that's what I have so far. See below:
********** For better visualization of the code, look at the last GitHub post that I created here: https://github.com/elastic/elasticsearch/issues/21486 **********
My NEST code:
-
Creating the index:
var response = CreateIndex(_currentIndex, i => i
.InitializeUsing(indexState)
.Mappings(m => m
.Map(t => t
.AutoMap()
.AllField(all => all
.Enabled(false)
)
.Properties(p => p
.Object(a => a
.Name(n => n.Attachment)
.AutoMap()
)
)
)
)
); -
Creating the pipeline for the attachment:
IPutPipelineResponse response = PutPipeline("attachments", p => p
.Description("Document attachment pipeline")
.Processors(pr => pr
.Attachment(a => a
.Field(f => f.Content)
.TargetField(f => f.Attachment)
)
.Remove(r => r
.Field(f => f.Content)
)
)
);
My mapping:
{
"es5" : {
"aliases" : { },
"mappings" : {
"topic" : {
"_all" : {
"enabled" : false
},
"properties" : {
"content" : {
"type" : "text",
"store" : true,
"analyzer" : "autocomplete",
"search_analyzer" : "search"
},
"delete" : {
"type" : "boolean"
},
"file" : {
"properties" : {
"author" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"content" : { I want to add analyzers for this
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"content_length" : {
"type" : "long"
},
"content_type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"date" : {
"type" : "date"
},
"detect_language" : {
"type" : "boolean"
},
"indexed_chars" : {
"type" : "long"
},
"keywords" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"language" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"title" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"hash_id" : {
"type" : "text"
},
"path" : {
"type" : "text"
},
"title" : {
"type" : "text"
}
}
}
},
"settings" : { ... }
}
}