As a result of my queries, only one result should be returned, but irrelevant results are coming

Hello

I have a question that I expect to return only one result.

GET /cvlist/_search
{
  "query": {
    "match": {
      "cvID": "17411189"
    }
  }
}

As a result of the query, another result with a similar cvID is returned.

{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "cvlist",
        "_type" : "cv",
        "_id" : "17411188",
        "_score" : 1.0,
        "_source" : {
          "userID" : 10069960,
          "cvID" : 17411188,
          "languageID" : 1
        }
      },
      {
        "_index" : "cvlist",
        "_type" : "cv",
        "_id" : "17411189",
        "_score" : 1.0,
        "_source" : {
          "userID" : 10062962,
          "cvID" : 17411189,
          "languageID" : 1
        }
      }
    ]
  }
}

What could be the reason for this, the old indexes are working normally, but there is this problem for the new index

Thanks for all

What is the mapping for the cvID field?

Hi

17411188 cvId result should not come in the cold, but why does it come?

Please provide the mapping for the field.

Are you saying the problem is with the mapping?

{
  "cvlist" : {
    "mappings" : {
      "cv" : {
        "dynamic_date_formats" : [
          "dateOptionalTime",
          "yyyy-MM-dd'T'HH:mm:ss.SSS"
        ],
        "date_detection" : true,
        "numeric_detection" : true,
        "properties" : {
          "cvID" : {
            "type" : "float"
          }
        }
      }
    }
  }
}

Yes, I suspect so. I have never tried a match query aganist a float field, so am not sure how it behaves. I would expect it to be either a keyword field (if it is an identifier and you do not need to query by integer range) or an integer (it does not to be a float based on the data you have shown so far).

Christian

PUT /cvlist/cv/_mapping?pretty
{
  "properties": {
    "cvID": {
      "type": "long"
    }
  }
}

the warning i get when i run the command
mapper [cvID] cannot be changed from type [float] to [long]
When I searched, these values were default floats when the first index was created.
there is no way to change this i need to recreate the directory
:sob:

You can not change existing mappings in Elasticsearch but may be able to add multi fields and perform an update for it to take effect. You can also reindex your data into a new index with appropriate mapping set via an index template.

IDs which are only retrieved using exact matches are best indexed as ‘keyword’ fields. The numeric field mappings like ‘long’ etc are optimised for performing range queries eg matching all the values between 1000 and 2000

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