edruiter
edruiter

Reputation: 1

Ranking SOLR results by query

I have a SOLR DIH-conig.xml (dataimporter) with multiple queries, querying different tables (or views) in Oracle 11.

I simply want SOLR to return results from one specific query first before returning the results from the other queries.

How should I configure this in DIH-config.xml?

Thanks.

regards, Erik

Upvotes: 0

Views: 186

Answers (1)

MatsLindh
MatsLindh

Reputation: 52902

You can't configure that in data-config.xml in any way - what Solr returns is based on what's in the index. The Data Import Handler only imports data into Solr, the SQL queries aren't used for anything outside of getting data into Solr.

However you can work around this through having a special field with static values returned from each query, effectively identifying which query the document was imported from.

In your SQL query, add an aliased field name as the priority of the document:

SELECT ..., 1000 AS priority FROM ...

In the second query, do the same, but with a higher priority value:

SELECT ..., 2000 AS priority FROM ...

This require defining a long / integer field named priority first if you're not running in schemaless mode.

When querying Solr, use this value as the first sort criteria (sort=priority, score). This will give all documents from the first query first, internally sorted by score, then from the last query, also internally sorted by score.

Upvotes: 1

Related Questions