- Creating multiple fields is also helpful if you want to use a field for autocompletion, search-as-you-type, or joins.
- If you only need a field for ranking, you might consider using the Rank Feature field and query for improved performance.
- build a more sophisticated query by adding and grouping different types of queries via things like the “bool” query.
- Mappings : Take an iterative approach to field mappings. That is, start by indexing the data using a subset of the content and the default settings. Then look to see what OpenSearch guessed for mappings and then modify those values accordingly to the requirements above and your insights.
- Look for additional fields we could either search or leverage in our query. Eg: manufacturer, color that satisifes the user intent.
- Using function query to impleme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
UNIFIED_FIELDS = ["title", "text"] | |
CASE_FIELDS = ["summary", "product", "description"] | |
SOLUTION_FIELDS = [ | |
"title", "solution_environment", "issue", | |
"solution_rootcause", "solution_diagnosticsteps", | |
"solution_resolution" | |
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install ujson | |
from fastcore.utils import dumps | |
def write_jsonl(cases: list, filename: str)->None: | |
''' Write a list of dictionaries to a jsonl file. This uses fastcore.utils `dumps` to serialize the dictionary to a string with `ujson` module. | |
Install `ujson` for faster serialization.''' | |
with open(filename, 'w') as file: | |
for item in cases: file.write(dumps(item) + '\n') | |
def read_jsonl(fname)->list: | |
''' Read a jsonl file into a list of dictionaries. This uses `ujson` module for faster deserialization. Install `ujson` for faster deserialization.''' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Altering resuts using painless - https://www.elastic.co/guide/en/elasticsearch/painless/7.10/painless-walkthrough.html | |
### Script score on price for doc 1 | |
### In these results, doc_a gets a score of price (5.99) + 1 (due to the match_all score) = 6.99. All else gets a score of 1 (match_all score) + 1 (the non “doc_a” case in the script) = 2. | |
POST searchml_test/_search | |
{ | |
"query": {"match_all": {}}, | |
"rescore": { |
NewerOlder