1

I have an index in Xapian, and every doc have a value (dinstinct) that I want to use at sort.

The problem is that when I use:

$enquire->set_sort_by_value_then_relevance(1);

Xapian will sort only by value or if I use:

$enquire->set_sort_by_relevance();

Xapian will sort only by relevance.

I want to sort by 50% relevance + 50%value, mix this type of sorts, not one after another.

Can I make this with Xapian?

Thank you

Daniel Dudas
  • 2,972
  • 3
  • 27
  • 39

1 Answers1

-1

For this kind of problem, what you need to do is use a PostingSource to affect the document weights that are fed to Xapian's ranking algorithm. If your PostingSource uses weights from a document value, then these will be taken account of alongside probabilistic relevance in the final weights and ordering.

There's an introduction to PostingSources that you should read, which includes an example (in Python) that gets pretty close to what you want to do here. (If you rewrote the WeightSource class to return the document value from get_weight(), and came up with a suitable implementation for get_maxweight(), you'll get what you want.)

I've never done this in PHP, but as I understand things it's supposed to work – so if it doesn't, that would be considered a bug and you should report it.

James Aylett
  • 3,332
  • 19
  • 20