This is a two-part question.
My documents look like this:
{"url": "https://someurl.com",
"content": "searchable content here",
"hash": "c54cc9cdd4a79ca10a891b8d1b7783c295455040",
"headings": "more searchable content",
"title": "Page Title"}
My first question is how to retrieve all documents where 'title' is exactly "No Title". I don't want a document with the title of "This Document Has No Title" to appear.
My second question is how to retrieve all documents where 'url' appears exactly in a long list of urls.
I'm using pyelasticsearch, but a generic answer in curl would also work.
You have to define a mapping for fields.
If you are looking for exact values (case sensitive), you can set index property to not_analyzed
.
Something like :
"url" : {"type" : "string", "index" : "not_analyzed"}
try this method. it's work.
import json
from elasticsearch import Elasticsearch
connection = Elasticsearch([{'host': host, 'port': port}])
elastic_query = json.dumps({
"query": {
"match_phrase": {
"UserName": "name"
}
}
})
result = connection.search(index="test_index", body=elastic_query)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With