Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:51:54+00:00 2026-06-12T05:51:54+00:00

I am trying to convert the below elasticsearch into pyes query and i could

  • 0

I am trying to convert the below elasticsearch into pyes query and i could not find example on how to use the range queries (especially for time stamps). Can someone help?

Elasticsearch Query

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "field1": "abcd"
          }
        },
        {
          "query_string": {
            "default_field": "@field2",
            "query": "efgh"
          }
        },
        {
          "range": {
            "timestamp": {
              "gte": "2012-08-14T20:45:09.000Z"
            }
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "@field3": "ijkl"
          }
        }
      ]

    }
  },
  "size": 1,
}

my Python script (using pyes) to get the results, i am using pyes 0.19.1

#!/usr/bin/python
# -*- coding: utf-8 -*-
from pyes import *

conn = ES('127.0.0.1:9200')


def main():
    try:
        q1= TextQuery('field1','abcd')
        q2=TextQuery('@field2','efgh')
        q3=Range('@timestamp','2012-08-14T20:45:09.000Z','2012-08-14T20:45:09.000Z')
        q4=TextQuery('@field3','ijkl')
        q = BoolQuery(must=[q1, q2,q3],must_not=[q4])
        results = conn.search(q,size='1')
        for r in results:
            print r;
    except:
        pass


if __name__ == '__main__':
    main() 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:51:56+00:00Added an answer on June 12, 2026 at 5:51 am

    Try replacing that Range with

    RangeQuery(qrange=ESRange('@timestamp',from_value='2012-08-14T20:45:09.000Z',to_value='2012-08-14T20:45:09.000Z'))
    

    I believe that will work, as long as your timestamp values match the format in your mapping.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert the below bit of code into VB (and obviously apply
I am trying to convert an array of the RECT structure (given below) into
I am trying to convert queries like below to types so that I won't
I'm trying to convert hexadecimal number to hexadecimal number presentation. for example is below.
I am trying to convert a string of the below format dd/MM/yyyy hh:mm:ss.fff into
I have spent a great deal of time trying to convert the query below
In the formula below I'm trying to convert a custom date string (yyyymmddhhmmss) into
I have the below windsor statement and trying to convert it into a structuremap
I am trying to convert the below mentioned SQL query to LINQ query Qry
I am trying to convert the code below to a shorthand linq, but not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.