elasticsearch


Search a list of names and categorizing each letter type


I want to index a large list of names using ES.
I want to distinguish between consonants and vowels in each word, and be able to search based on the position of each letter and if it is a consonant or a vowel.
So say the name like:
JOHN
I want to enter this:
CVCC
and when I run the search, JOHN should be in the result set.
Is it possible somehow to index names in elastic search such that I could index and then search them using the tokens C and V for vowel?
So somehow Elasticsearch will have to index the character types for each position for each word, how can this be done?
You can do it with pattern_replace char filters in a custom analyzer. Also, in my solution I have used a sub-field for the custom analyzer, thinking maybe that you will want other kinds of searches on the name field, the consonants-vowels one being only one of them.
DELETE test
PUT test
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "keyword",
"char_filter": [
"replace_filter_lowercase_CONS",
"replace_filter_uppercase_CONS",
"replace_filter_lowercase_VOW",
"replace_filter_uppercase_VOW"
]
}
},
"char_filter": {
"replace_filter_lowercase_CONS": {
"type": "pattern_replace",
"pattern": "[b-df-hj-np-tv-z]{1}",
"replacement": "c"
},
"replace_filter_uppercase_CONS": {
"type": "pattern_replace",
"pattern": "[B-DF-HJ-NP-TV-Z]{1}",
"replacement": "C"
},
"replace_filter_lowercase_VOW": {
"type": "pattern_replace",
"pattern": "[aeiou]{1}",
"replacement": "v"
},
"replace_filter_uppercase_VOW": {
"type": "pattern_replace",
"pattern": "[AEIOU]{1}",
"replacement": "V"
}
}
}
},
"mappings": {
"test": {
"properties": {
"name": {
"type": "text",
"fields": {
"cons_vow": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}
}
}
}
POST /test/test/1
{"name":"JOHN"}
POST /test/test/2
{"name":"Andrew"}
POST /test/test/3
{"name":"JOhn DOE"}
GET /test/_search
{
"query": {
"term": {
"name.cons_vow": {
"value": "CVCC"
}
}
}
}

Related Links

How do I stop Kibana in Windows?
Elasticsearch query string query with not equal to?
How to profile search query in elasticsearch 1.6?
Regex on Term aggregations with phrase
Plot a count of paired events with kibana
How to configure docker-compose for storing data of Elastic search out-side of docker container?
can i run multiple instance of logstash in the same server?
Docker-compose.yml Is not working for elasticserch
Looking for someone to help me with ElasticSearch
quote estimation using elastisearch
Elastic Search Ingest Node Feature: How to use “Remove processor” to remove fields from document before persisting
Elasticsearch: High CPU usage by Lucene Merge Thread
Elasticsearch find distinct documents
Need care for filter order?
elasticsearch/graylog finding uuid string
Logstash output logs to Elasticsearch server ConfigurationError

Categories

HOME
functional-programming
systemd
nsview
braintree
out-of-memory
swift2
navigation
cqrs
slide
fullcalendar-scheduler
orange-api
reselect
android-5.1.1-lollipop
playframework-2.0
robolectric
parceler
activeadmin
android-permissions
coreldraw
uilocalnotification
es6-modules
mongodb-3.4
microsoft-certifications
gsp
winrm
transform
busboy
textmate2
pdfnet
testlink
selenide
reset
best-buy-api
word-cloud
yoast
vesta
bit-shift
spongycastle
libreoffice-writer
uiautomatorviewer
test-data
case-when
.when
msxml
hmmlearn
ogg
libharu
dcount
callouts
coovachilli
right-to-left
android-async-http
distributed-cache
onepage-checkout
wepay
cryptojs
nastran
google-gdk
relational-model
shoes
android-audiomanager
htmltidy
operands
iodocs
utf8-decode
treeline
sqlbindparameter
sql-function
bittorrent-sync
preorder
gpu-programming
map
lsa
form-for
flv
significant-digits
nsmutablestring
clrprofiler
platform-independent
series-40
autosize
fitch-proofs
uploading
firefly-mv
azure-acs
photo-management
css-friendly
digiflow
channelfactory
mongrel2
gaelyk
hungarian-notation
urchin
cleartype
gtktextview
xap
comment-conventions
levels

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App