I have a csv file which contains four columns(oNumber, oName, userids, userID) and value of first two columns I want to put in input and value of remaining two column's value I want to put in userid.
Mapping:
PUT somki
{
"mappings": {
"_doc" : {
"properties" : {
"suggest" : {
"type" : "completion",
"contexts": [
{
"name": "userid",
"type": "category"
}
]
}
}
}
}
}
Indexing:
POST somki/_doc/
{
"suggest": {
"input": ["123","asb"],
"contexts": {
"userid": ["99568656541578","abhi"]
}
}
}
Suggester:
GET somki/_search
{
"suggest": {
"suggestion" : {
"prefix" : "asb",
"completion" : {
"field" : "suggest",
"contexts": {
"userid": [ "99568656541578" ]
},
"fuzzy" : {
"fuzziness" : 2
}
}
}
}
}
This method works well but I have to index data manually for every row. So I want to use logstash and here is my .conf file
input {
file {
path => "C:\Users\ramesh\Downloads\elasticsearch\Data\Book1.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}generator {
lines => ['oNumber,oName,userids,userID']
count => 1
}
}filter {
grok {
match => { "message" => "%{NOTSPACE:[suggest][input]},%{NOTSPACE:[suggest][input]},%{NOTSPACE:[suggest][contexts][userid]},%{NOTSPACE:[suggest][contexts][userid]}" }
}
}output {
elasticsearch {
hosts => "http://localhost:9200"
index => "somki"
user => elastic
password => "elastic"
}
stdout { codec => rubydebug }
}
But suggester is not showing any output, Why? And how to solve it.