Logstash to create the complete suggester

Hi!
I am going to make completion suggester in my search page, I used the display_name as the text, and I would like to insert id as the weight for sorting the suggester.
Here is my logstash filter

filter {
if [type] == "product"{
	mutate {
		add_field => { "product_suggest" => "%{display_name}" }
		add_field => { "weight" => "%{id}" }
		add_field => { "product_suggester" => "%{display_name}" }
		remove_field => ["attribute_value_en", "attribute_value_sc"]
	}
}
if [type] == "merchant"{
	mutate {
		add_field => { "merchant_suggest" => "%{merchant_name}" }
		add_field => { "weight" => "%{id}" }
		add_field => { "merchant_suggester" => "%{merchant_name}" }
	}
}
}

Here is the example I try to write

PUT music/song/1?refresh
{
"suggest" : [
    {
        "input": "Nevermind",
        "weight" : 10
    },
    {
        "input": "Nirvana",
        "weight" : 3
    }
]
}

I don't understand what you're trying to do. How is Logstash related to the search form completion feature on your web page? And what exact problem are you facing?

In the example,
the Nevermind is the suggester with weight 10.

And I am going to use logstash to make
the display_name as the suggester with wight follow the id

I find that it works with the following filter

filter {
if [type] == "product"{
	mutate {
		add_field => { "[product_suggest][input]" => "%{display_name}"}
		add_field => { "[product_suggest][weight]" => "%{id}"}
		remove_field => ["attribute_value_en", "attribute_value_sc"]
	}
}
if [type] == "merchant"{
	mutate {
		add_field => { "[merchant_suggest][input]" => "%{merchant_name}"}
		add_field => { "[merchant_suggest][weight]" => "%{id}"}
	}
    }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.