elasticsearch-dsl

negative lookahead Regexp doesnt work in ES dsl query

99封情书 提交于 2019-12-02 00:44:15
问题 The mapping of my Elastic search looks like below: { "settings": { "index": { "number_of_shards": "5", "number_of_replicas": "1" } }, "mappings": { "node": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" }, "query": { "properties": { "regexp": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" } } } } } } } } } Problem is : I am forming ES queries using elasticsearch_dsl Q(). It works perfectly fine in most of the cases when my

negative lookahead Regexp doesnt work in ES dsl query

狂风中的少年 提交于 2019-12-01 21:22:24
The mapping of my Elastic search looks like below: { "settings": { "index": { "number_of_shards": "5", "number_of_replicas": "1" } }, "mappings": { "node": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" }, "query": { "properties": { "regexp": { "properties": { "field1": { "type": "keyword" }, "field2": { "type": "keyword" } } } } } } } } } Problem is : I am forming ES queries using elasticsearch_dsl Q(). It works perfectly fine in most of the cases when my query contains any complex regexp. But it totally fails if it contains regexp character '!' in it. It

how to log or print python elasticsearch-dsl query that gets invoked

喜夏-厌秋 提交于 2019-12-01 09:11:44
I am using elasticsearch-dsl for my python application to query elastic search. To debug what query is actually getting generated by elasticsearch-dsl library, I am unable to log or print the final query that goes to elasticsearch. For example, like to see the request body sent to elasticsearch like this : { "query": { "query_string": { "query": "Dav*", "fields": ["name", "short_code"], "analyze_wildcard": true } } } Tried to bring the elasticsearch log level to TRACE. Even then, unable to see the queries that got executed. Take a look at my blog post here , "Slowlog settings at index level"

Fetch only filtered nested objects from index in elasticsearch

半世苍凉 提交于 2019-11-27 16:21:28
I have a document with nested objects, something like this: { "title" : "Title 1", "books": [{ "book_title": "b title 1", "year": 2014 }, { "book_title": "b title 2", "year": 2015 }] } Now I need to filter the books on by title (not book_title) and year (let's say 2014). The output I need will be: { "title" : "Title 1", "books": [{ "book_title": "b title 1", "year": 2014 }] } When I use a nested filter I get all the nested objects even if they don't match. How can I fetch only the matched nested objects? You need to use the nested inner_hits feature like below. { "_source": [ "title" ], "query