-
-
Save carlosdelest/c5d023567ab446679076f1751deaf25b to your computer and use it in GitHub Desktop.
semantic_query test
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
PUT _ml/trained_models/.elser_model_2 | |
{ | |
"input": { | |
"field_names": ["text_field"] | |
} | |
} | |
PUT _inference/sparse_embedding/my-elser-model | |
{ | |
"service": "elser", | |
"service_settings": { | |
"num_allocations": 1, | |
"num_threads": 1 | |
}, | |
"task_settings": {} | |
} | |
PUT test-semantic | |
{ | |
"mappings": { | |
"properties": { | |
"infer_field": { | |
"type": "semantic_text", | |
"model_id": "my-elser-model" | |
}, | |
"non_infer_field": { | |
"type": "text" | |
}, | |
"another_infer_field": { | |
"type": "semantic_text", | |
"model_id": "my-elser-model" | |
} | |
} | |
} | |
} | |
PUT test-semantic/_doc/doc1 | |
{ | |
"infer_field": "these are not the droids you're looking for", | |
"non_infer_field": "hello", | |
"another_infer_field": "carry on" | |
} | |
PUT test-semantic/_doc/doc2 | |
{ | |
"infer_field": "Whose motorcycle is this?", | |
"non_infer_field": "It's a chopper, baby", | |
"another_infer_field": "Whose chopper is this?" | |
} | |
PUT test-semantic/_doc/doc2 | |
{ | |
"infer_field": "And you know what they call a... a... a Quarter Pounder with Cheese in Paris", | |
"non_infer_field": "They don't call it a Quarter Pounder with cheese?", | |
"another_infer_field": "No man, they got the metric system. They wouldn't know what a Quarter Pounder is" | |
} | |
GET test-semantic/_search | |
{ | |
"query": { | |
"semantic_query": { | |
"infer_field": { | |
"query": "burger" | |
} | |
} | |
} | |
} | |
GET test-semantic/_search | |
{ | |
"query": { | |
"semantic_query": { | |
"infer_field": { | |
"query": "robots" | |
} | |
} | |
} | |
} | |
GET test-semantic/_search | |
{ | |
"query": { | |
"semantic_query": { | |
"infer_field": { | |
"query": "motorbike" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment