Skip to content

Commit

Permalink
change simple concept search to score based on aggregate relevance, f…
Browse files Browse the repository at this point in the history
…ix root_path default value
  • Loading branch information
frostyfan109 committed Oct 10, 2024
1 parent 0de6dfa commit 6ec1355
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/dug/core/async_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,42 @@ def get_simple_search_query(self, query):
"fields": ["name", "description", "search_terms"],
"default_operator": "and",
"flags": "OR|AND|NOT|PHRASE|PREFIX"
},
}
}
simple_query_string_search = {
"query": query,
"default_operator": "and",
"flags": "OR|AND|NOT|PHRASE|PREFIX"
}
search_query = {
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"simple_query_string": {
**simple_query_string_search,
"fields": ["name"]
}
},
{
"simple_query_string": {
**simple_query_string_search,
"fields": ["description"]
}
},
{
"simple_query_string": {
**simple_query_string_search,
"fields": ["search_terms"]
}
}
]
}
},
"score_mode": "sum"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dug/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

APP = FastAPI(
title="Dug Search API",
root_path=os.environ.get("ROOT_PATH", "/"),
root_path=os.environ.get("ROOT_PATH", ""),
)

APP.add_middleware(
Expand Down

0 comments on commit 6ec1355

Please sign in to comment.