Comments (4)
Multiple sort keys come in handy when some of the document hits are missing or equal sort values for earlier keys.
Here is an example test case that could help -
https://github.com/blevesearch/bleve/blob/v2.3.7/examples_test.go#L443
from bleve.
This doesn't seem to be quite what I was looking for. As far as I can tell, it's sorting only based on age while what I was looking for is something like sorting by the multiplication product of two relevance score and a field in the document. FWIW, I finally came up with this, which seems to work:
func (so *RankedSort) UpdateVisitor(field string, term []byte) {
switch field {
case "pRank":
if len(term) > len(so.pRank) {
so.pRank = make([]byte, len(term))
copy(so.pRank, term)
}
case "hRank":
if len(term) > len(so.hRank) {
so.hRank = make([]byte, len(term))
copy(so.hRank, term)
}
}
}
func (so *RankedSort) Value(a *search.DocumentMatch) string {
prp, _ := numeric.PrefixCoded(so.pRank).Int64()
pr := math.Float64frombits(uint64(prp))
hrp, _ := numeric.PrefixCoded(so.hRank).Int64()
hr := math.Float64frombits(uint64(hrp))
so.pRank = so.pRank[:0]
so.hRank = so.hRank[:0]
score := numeric.Float64ToInt64((a.Score + 1) * (pr + 1) * (hr + 1))
return string(numeric.MustNewPrefixCodedInt64(score, 0))
}
(I'm pretty sure how I use the absolute value of score and multiply it by other values is technically incorrect, since the score value does not have any bounds that I'm aware of; would love any suggestions on that front too.)
from bleve.
Ah I see, for custom sorting - we've provided an API for the SearchRequest that you could leverage. I suppose you're registering your RankedSort
using this -
https://github.com/blevesearch/bleve/blob/v2.3.7/search.go#L629
The internal score determination is based on the tf-idf algorithm. Boosting is the only way we allow users to adjust/influence this score generated for your document hits.
from bleve.
I'm using SortByCustom. I didn't know about SetSortFunc. Looks like it's more concerned with the implementation of sort, than scoring, or did I get that wrong?
Are you saying that what I'm doing is borderline unsupported? Boost it is not gonna work for my use case, because I want the scores to come partially from relevance, and partially by the rank of each item. This is a small search engine, and pRank is actually PageRank; the score*rank multiplication was the best I could come up with to achieve what I wanted. It does seem to be working mostly. I just don't like that I'm multiplying by score, which I don't know the dimensions or bounds of, and indeed I think I read somewhere it's not even meant to be comparable between different searches.
from bleve.
Related Issues (20)
- website https://www.blevesearch.com is messy due to invalid(?) ssl cert HOT 5
- bug:Unstable, keywords that can be searched for in the first few meters and seconds, but cannot be indexed
- Very poor search performance
- github.com/blevesearch/bleve/v2/http/search.go bug? HOT 1
- Current `bleve` release broken by more recent change? HOT 4
- search_geoshape.go:107:32: not enough arguments in call to geojson.FilterGeoShapesOnRelation HOT 5
- NewRegexpQuery cannot return the correct result HOT 4
- Panic in ParseFromKeyValue HOT 1
- can not search bool fields HOT 1
- ANSI Windows Console Highlighting
- runtime error: invalid memory address or nil pointer dereference HOT 2
- html search error HOT 1
- How to lower hit's score/position if specific field is empty? HOT 2
- Adding synonyms to search queries HOT 1
- Configuration for only in-memory storage HOT 2
- [Bug] Spanish analyzer not normalizing all accented words. HOT 3
- How can I use the Vector Search feature? HOT 1
- Handling a field whose value may be a different language? HOT 1
- Index out of range since v2 installed HOT 2
- What is the function of segmentMerge.oldNewDocNums?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bleve.