Why term query not returning the document that contains the exact term in 7.3.2

I have a order_no with value '100000076268946605' in my index.
The following term query does not return me the document with order_no '100000076268946605':

{
  "query": {
          "term": {
            "order_no": {
              "value": "100000076268946605"
            }
          }
  }
}

The term query find another document like this:

{ - 
  "took": 2,
  "timed_out": false,
  "_shards": { - 
    "total": 2,
    "successful": 2,
    "skipped": 0,
    "failed": 0
  },
  "hits": { - 
    "total": { - 
      "value": 1,
      "relation": "eq"
    },
    "max_score": 14.483531,
    "hits": [ - 
      { - 
        "_index": "trans_drp_experience_store_service_order",
        "_type": "_doc",
        "_id": "1438331557453504524",
        "_score": 14.483531,
        "_source": { - 
          "activity_amt": "",
          "buyer_name": "tLddgedggieda1dlaxg==",
          "buyer_phone": "Yghzx1rfi4pchdfdfedfdgdfdaf",
          "code_value": "866028053541177",
          "coupon_amt": "0.0",
          "data_source": "1",
          "etl_time": "2021-09-18 18:15:01.127",
          "is_booking": "no",
          "is_gift": "no",
          "member_amt": "0.0",
          "online_order_send_way": "10",
          "order_detail_id": 1438331557453504500,
          "order_detail_status": "",
          "order_no": 100000076268946610,
          "order_type": "10",
          "price_adjustment_amt": "",
          "product_amt": "1799.0",
          "product_category_name": "",
          "product_final_amt": "1799.0",
          "product_name": "phone",
          "product_qty": "1",
          "product_retail_amt": "1799.0",
          "sale_time": "2021-09-16 10:41:05",
          "saler_name": "",
          "shop_name": "",
          "sku_code": "110010331209",
          "sku_name": "",
          "source": "SALE ORDER",
          "spu_name": "",
          "unit": ""
        }
      }
    ]
  }
}

The term query return the document contains order_no with value '100000076268946610'.
'100000076268946605'

My index settings like this:

{ - 
  "trans_drp_experience_store_service_order": { - 
    "settings": { - 
      "index": { - 
        "refresh_interval": "1s",
        "number_of_shards": "2",
        "provided_name": "trans_drp_experience_store_service_order",
        "creation_date": "1631958631725",
        "number_of_replicas": "2",
        "uuid": "ax6vbL6RShGjfvcPXqLOxw",
        "version": { - 
          "created": "7030299"
        }
      }
    }
  }
}

mappings
{ - 
  "trans_drp_experience_store_service_order": { - 
    "mappings": { - 
      "dynamic_templates": [ - 
        { - 
          "strings_not_analyzed": { - 
            "match_mapping_type": "string",
            "mapping": { - 
              "type": "keyword"
            }
          }
        }
      ],
      "properties": { - 
        "activity_amt": { - 
          "type": "keyword"
        },
        "buyer_name": { - 
          "type": "keyword"
        },
        "buyer_phone": { - 
          "type": "keyword"
        },
        "code_value": { - 
          "type": "keyword"
        },
        "coupon_amt": { - 
          "type": "keyword"
        },
        "data_source": { - 
          "type": "keyword"
        },
        "etl_time": { - 
          "type": "keyword"
        },
        "is_booking": { - 
          "type": "keyword"
        },
        "is_gift": { - 
          "type": "keyword"
        },
        "member_amt": { - 
          "type": "keyword"
        },
        "online_order_send_way": { - 
          "type": "keyword"
        },
        "order_detail_id": { - 
          "type": "keyword"
        },
        "order_detail_status": { - 
          "type": "keyword"
        },
        "order_no": { - 
          "type": "keyword"
        },
        "order_type": { - 
          "type": "keyword"
        },
        "price_adjustment_amt": { - 
          "type": "keyword"
        },
        "product_amt": { - 
          "type": "keyword"
        },
        "product_category_name": { - 
          "type": "keyword"
        },
        "product_final_amt": { - 
          "type": "keyword"
        },
        "product_name": { - 
          "type": "keyword"
        },
        "product_qty": { - 
          "type": "keyword"
        },
        "product_retail_amt": { - 
          "type": "keyword"
        },
        "sale_time": { - 
          "type": "keyword"
        },
        "saler_name": { - 
          "type": "keyword"
        },
        "shop_name": { - 
          "type": "keyword"
        },
        "sku_code": { - 
          "type": "keyword"
        },
        "sku_name": { - 
          "type": "keyword"
        },
        "source": { - 
          "type": "keyword"
        },
        "spu_name": { - 
          "type": "keyword"
        },
        "unit": { - 
          "type": "keyword"
        }
      }
    }
  }
}

I am confused why term query does not return the desired document.

Numbers in JSON has finite precision so it would be better if you stored the order number as a string.

Hi.
Can you find document with order_no "100000076268946605" using another filter?
And show it in reply.

P.S Simple answer on your question - it doesn`t exist=))

It's weird. My dynamic templates make map all fields only as keywords

I tried several other filter, but it still not work .

{
  "query": {
    "match": {
      "order_no": {
        "query": "100000076268946605"
      }
    }
  }
}

same result

{ - 
  "took": 12,
  "timed_out": false,
  "_shards": { - 
    "total": 2,
    "successful": 2,
    "skipped": 0,
    "failed": 0
  },
  "hits": { - 
    "total": { - 
      "value": 1,
      "relation": "eq"
    },
    "max_score": 14.183976,
    "hits": [ - 
      { - 
        "_index": "trans_drp_experience_store_service_order",
        "_type": "_doc",
        "_id": "1438331557453504524",
        "_score": 14.183976,
        "_source": { - 
          "activity_amt": "",
          "buyer_name": "tLddgedggieda1dlaxg==",
          "buyer_phone": "Yghzx1rfi4pchdfdfedfdgdfdaf",
          "code_value": "866028053541177",
          "coupon_amt": "0.0",
          "data_source": "1",
          "etl_time": "2021-09-18 19:38:04.536",
          "is_booking": "n",
          "is_gift": "n",
          "member_amt": "0.0",
          "online_order_send_way": "10",
          "order_detail_id": 1438331557453504500,
          "order_detail_status": "",
          "order_no": 100000076268946610,
          "order_type": "10",
          "price_adjustment_amt": "",
          "product_amt": "1799.0",
          "product_category_name": "",
          "product_final_amt": "1799.0",
          "product_name": "",
          "product_qty": "1",
          "product_retail_amt": "1799.0",
          "sale_time": "2021-09-16 10:41:05",

index 10192510 documents, Only order_no "100000076268946605“ can not work.

heh=)
I mean find this document using filter without order_no, may be you can find it using another fields.

Because now it look like order_no 100000076268946605 doesn`t exist in your index.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.