Skip to content

Commit

Permalink
Fix boost parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaredoug committed Dec 27, 2023
1 parent 12908c2 commit c9af718
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion searcharray/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def listify(x):
# bigram_fields = parse_field_boosts(pf2) if pf2 else {}
# trigram_fields = parse_field_boosts(pf3) if pf3 else {}

num_search_terms, search_terms = parse_query_terms(frame, q, qf)
num_search_terms, search_terms = parse_query_terms(frame, q, list(query_fields.keys()))

term_scores = []
for term_posn in range(num_search_terms):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# For a discussion on single-sourcing the version across setup.py and the
# project code, see
# https://packaging.python.org/guides/single-sourcing-package-version/
version="0.0.21", # Required
version="0.0.22", # Required
# This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field:
# https://packaging.python.org/specifications/core-metadata/#summary
Expand Down
13 changes: 13 additions & 0 deletions test/test_solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ def everythings_a_b_tokenizer(text: str) -> List[str]:
0],
"params": {'q': "foo bar", 'qf': ["title", "body"]},
},
"boost_title": {
"frame": {
'title': lambda: PostingsArray.index(["foo bar bar baz", "data2", "data3 bar", "bunny funny wunny"]),
'body': lambda: PostingsArray.index(["buzz", "data2", "data3 bar", "bunny funny wunny"])
},
"expected": [lambda frame: sum([frame['title'].array.bm25("foo")[0] * 10,
frame['title'].array.bm25("bar")[0] * 10]),
0,
lambda frame: max(frame['title'].array.bm25("bar")[2] * 10,
frame['body'].array.bm25("bar")[2]),
0],
"params": {'q': "foo bar", 'qf': ["title^10", "body"]},
},
"pf_title": {
"frame": {
'title': lambda: PostingsArray.index(["foo bar bar baz", "data2", "data3 bar", "bunny funny wunny"]),
Expand Down

0 comments on commit c9af718

Please sign in to comment.