-1

I have setup Solr 5.1.0 with proper data importation from MYSQL database. It is working good.

But I want exact match results or relevant to that only.

like,

Dancers in Mumbai

It gives all results which contains "dancers + mumbai" and only "dancers" + only "mumbai" keywords. I want result which must contains only "dancers + mumbai" not others.

femtoRgon
  • 32,893
  • 7
  • 60
  • 87

2 Answers2

1

This is not a complete answer, but it's the direction I'm trying to take with a similar problem. Comments are very welcome.

Step 1: Implement multiple Solr cores, core 1 is "jobs" (dancers/lawyers/etc), and core 2 is "cities" (mumbai/chennai/etc).

Step 2: Query each core for exact matches, so implement the KeywordTokenizerFactory on the relevant field to find exact matches only. This will give you all the matches accross cores (e.g. jobs: dancers and cities:mumbai).

Step 3: Perform your general query using EDisMax for a user-friendly search (e.g. searching for "dancers in mumbai" accross many fields), and use the boost field to boost the jobs/cities found in the earlier query.

I would love to know if there is a better way of doing something this elaborate, but I have not found it yet. Hope it helps.

mils
  • 1,878
  • 2
  • 21
  • 42
0

Using required terms like: +dancers +mumbia

Or a phrase query: "dancers in mumbia"

Would work.

You can also set the default operator for your query to be "AND", using the q.op parameter.

femtoRgon
  • 32,893
  • 7
  • 60
  • 87
  • I have 2 different fields like **talent_name** & **city** both are independent. so it fetch data from both. but its gives results that contains only **dancers** & only **mumbai** contained results with common result. I want only that results which contains **dancer** as talent && **mumbai** as city. – Mayur Champaneria Jul 07 '15 at 06:02
  • @MayurChampaneria So, query for that. I that case, a phrase query isn't really relevant, but either of the other two options will work just fine. [Reading the query parser syntax documentation might help.](http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html) – femtoRgon Jul 07 '15 at 06:05