Arnold Zokas
Arnold Zokas

Reputation: 8560

Sort optional fields in Lucene.net

I have a Lucene index which:

I have a requirement to sort search results by Title and Tag fields. At the moment, if none of the documents in the index contain Tag field, the search throws an SystemException: "field "Tag" does not appear to be indexed".

I am aware this behaviour is by design.
Is there a way to tell Lucene to optionally sort by Tag field if it exists?

Upvotes: 0

Views: 406

Answers (2)

Wyatt Barnett
Wyatt Barnett

Reputation: 15673

What I'd do here is add another field that is concatenated title and tags and then sort by that -- should get you what you want and you'll still be able to ride the lucene rails.

Upvotes: 1

Anonymous
Anonymous

Reputation: 144

No. You have to implement a custom sort on the search results

Upvotes: 1

Related Questions