Improving Solr Search Query / Filter

Viewed 59

I am new to Solr, but looking to use it as part of my site for indexing ingredients.

I'm looking for advice to improve the query below. I've tried NGram filtering but it doesn't seem to work. I'm not sure why 'red onion' would score more highly than 'red pepper' ? It makes no sense to me. Ideally a user would search for 'red onion' or 'red onions' and these would score higher.

any advice would be appreciated! I have already tried porterstemming filters, and ngram filtering, but these don't seem to have any effect.

enter image description here

1 Answers

I would suggest you to go for exact match here. To achieve the same please apply the string field type to your field as below.

<field name="name" type="string" indexed="true" stored="true" docValues="true" />

I have indexed data as below.

{
"id":"1",
"name" : "red onion"
},
{
"id":"2",
"name" : "red pepper"
},
{
"id":"3",
"name" : "red cabbage"
},
{
"id":"4",
"name" : "red chilli"
}

when I search for the name:red onion, I get red onion on top. Please refer the below solr query screen for the same.

Screen

The screenshot with score and debugQuery is on.

enter image description here

Related