Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
elasticsearchquerygenerator
Advanced tools
Create Complex Elastic Search Query in Seconds Please see documentation for more details
While i was working with Elastic Search i found it very difficult to write complex queries as most of query are deep Nested
Thats the reason i decided to make a helper class that can generate complex Elastic Search query in Seconds
Library can be used to generate complex aggregation Query , Geo location Query (AND | OR | NOT ) any set of combination is possible
in addition to all mentioned above you can also generate auto complete query in matter of seconds
please see examples below on how to use this module.
if you have any questions or suggestion please drop me an email at shahsoumil519@gmail.com
Learn More : https://www.youtube.com/watch?v=C-JKcMM6IXE&t=2548s
Constructor:
Field:
Boost:
Operation
Analyzer:
pip install elasticsearchquerygenerator
from elasticsearchquerygenerator.elasticsearchquerygenerator import ElasticSearchQuery
import json
def main():
helper = ElasticSearchQuery(size=100, BucketName="MyBuckets")
# match phrase
query=helper.match_phrase(field="myfeild", value="myvalue", operation='must')
# terms
query=helper.terms(field="myfeild", value="myvalue", operation='must')
# Feild Exists
query = helper.exists(field='comp feild', operation="must")
#Match
query=helper.match(field="MMMMM", value="myvalue", operation='must')
# Geo Queires
query = helper.add_geoqueries(radius="100", lat="22", lon="33")
# Aggreation
helper.add_aggreation(aggregate_name="FirstName", field="field1",type='terms',sort='desc', size=3)
helper.add_aggreation(aggregate_name="SecondName", field="field2",type='terms',sort='desc', size=3)
helper.add_aggreation(aggregate_name="ThirdName", field="field3",type='terms',sort='desc', size=3)
query = helper.complete_aggreation()
query = helper.query_string(default_field="DEFAULT",query="X OR Y",operation='must')
query = helper.add_geo_aggreation(field="AAAA", lat="22", lon="43",aggregate_name="my_distance")
print(json.dumps(query, indent=3))
if __name__ == "__main__":
main()
{
"_source": [],
"size": 100,
"min_score": 0.5,
"query": {
"bool": {
"must": [
{
"match_phrase": {
"myfeild": {
"query": "myvalue"
}
}
},
{
"match_phrase": {
"myfeild": {
"query": "myvalue"
}
}
},
{
"term": {
"myfeild": "myvalue"
}
},
{
"exists": {
"field": "comp feild"
}
},
{
"match": {
"MMMMM": {
"query": "myvalue"
}
}
},
{
"match": {
"MMMMM": {
"query": "myvalue"
}
}
},
{
"query_string": {
"default_field": "DEFAULT",
"query": "X OR Y"
}
}
],
"filter": [
{
"geo_distance": {
"distance": "100mi",
"null": {
"lat": "22",
"lon": "33"
}
}
}
],
"should": [],
"must_not": []
}
},
"aggs": {
"FirstName": {
"terms": {
"field": "field1",
"order": {
"_count": "desc"
},
"size": 3
}
},
"SecondName": {
"terms": {
"field": "field2",
"order": {
"_count": "desc"
},
"size": 3
}
},
"ThirdName": {
"terms": {
"field": "field3",
"order": {
"_count": "desc"
},
"size": 3
}
},
"my_distance": {
"geo_distance": {
"field": "AAAA",
"origin": "22,43",
"unit": "mi",
"ranges": [
{
"to": 0
},
{
"from": 0,
"to": 25
},
{
"from": 25,
"to": 50
},
{
"from": 50,
"to": 75
},
{
"from": 75,
"to": 100
},
{
"from": 100
}
]
}
}
}
}
from elasticsearchquerygenerator.elasticsearchquerygenerator import ElasticSearchQuery
import json
def autocomplete():
helper = ElasticSearchQuery(size=0, BucketName="MyBuckets")
query = helper.autocomplete_1(field="title",value="n", size=25,sort='desc')
print(json.dumps(query, indent=3))
if __name__ == "__main__":
main(autocomplete
{
"_source": [],
"size": 0,
"min_score": 0.5,
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"title": {
"query": "n"
}
}
}
],
"filter": [],
"should": [],
"must_not": []
}
},
"aggs": {
"auto_complete": {
"terms": {
"field": "title",
"order": {
"_count": "desc"
},
"size": 25
}
}
}
}
** sasirajpuvvada **
Bachelor in Electronic Engineering | Masters in Electrical Engineering | Master in Computer Engineering |
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
Create Complex Elastic Search Query in Seconds Please see documentation for more details
We found that elasticsearchquerygenerator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.