Elasticsearch Morphological Search
Morphological search handles word forms: "running", "ran", "run" all match query "run" (with proper stemming).
Using Stemmer Filter
PUT /articles
{
"settings": {
"analysis": {
"filter": {
"english_stemmer": {
"type": "stemmer",
"language": "english"
}
},
"analyzer": {
"english_with_stemming": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "stop", "english_stemmer"]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "english_with_stemming",
"search_analyzer": "english_with_stemming"
}
}
}
}
POST /articles/_doc
{
"content": "Running is great for health. The runner finished the race quickly."
}
GET /articles/_search
{
"query": {
"match": {
"content": "run" // matches: running, runner, run
}
}
}
Russian Morphology with Mystem
PUT /russian_docs
{
"settings": {
"analysis": {
"analyzer": {
"russian_morphology": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "russian_stop", "mystem_morphology"]
}
},
"filter": {
"russian_stop": {
"type": "stop",
"stopwords": "_russian_"
}
}
}
},
"mappings": {
"properties": {
"text": {
"type": "text",
"analyzer": "russian_morphology"
}
}
}
}
POST /russian_docs/_doc
{
"text": "Поиск текстов по морфологическим основам"
}
GET /russian_docs/_search
{
"query": {
"match": {
"text": "искать" // matches: поиск, поискам, искать, поисках
}
}
}
Synsets for Semantic Search
PUT /books
{
"settings": {
"analysis": {
"filter": {
"synonym_filter": {
"type": "synonym",
"synonyms": [
"author,writer,novelist",
"book,novel,publication",
"fast,quick,rapid,swift"
]
}
},
"analyzer": {
"synonym_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "synonym_filter"]
}
}
}
}
}







