I'm building a search feature that allows users to filter by certain field. One of the field is DOI. Filtering by DOI should only return results with exact match.
I'm trying to index the following object:
public class PaperElasticSearchModel
{
public string Title { get; set; }
public string Abstract { get; set; }
public string Keywords { get; set; }
public string DOI { get; set; }
public int Year { get; set; }
public string[] Author { get; set; }
}
The field DOI is will have a similar format to this: 10.1523/JNEUROSCI.18-04-01622.1998.
Below is the setting for the index
Client.Indices.Create(index, pub => pub
.Settings(s => s
.Analysis(descriptor => descriptor
.Analyzers(analyzer => analyzer
.Custom("custom_analyzer", ca => ca
.Filters("lowercase", "stop", "classic", "word_delimiter")
)
)
.TokenFilters(bases => bases
.EdgeNGram("custom_analyzer", td => td
.MinGram(2)
.MaxGram(25))
)
)
.Setting(UpdatableIndexSettings.MaxNGramDiff, 23)
)
.Map<PubScreenSearch>(m => m
.AutoMap()
.Properties(p => p
.Text(t => t
.Name(f => f.Author)
.Analyzer("custom_analyzer"))
.Text(t => t
.Name(f => f.Keywords)
.Analyzer("custom_analyzer"))
.Text(t => t
.Name(f => f.Title)
.Analyzer("custom_analyzer"))
.Keyword(t => t
.Name(f => f.DOI)
)
)));
It looks like that field was mapped using dynamic mapping. This means it has a multi fieldkeyword that is mapped as keyword, so use this instead as follows:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.