Getting Case insensitive Response in Hits

Hi all
I am getting case Insensitive Data in Hits(SearchResponse ) even I am having Case Sensitive Data in Elasticsearch index

like

index contains {
customerName :"David",
departmentName:"IT",
applicantName:"Raju"}

but I am getting Hits as 
customername :"David",
departmentname:"IT",
applicantname:"Raju"}

I don't see what's wrong.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

Hi David,

        PUT index/_doc/1
        {
          "companyName": "CA",
         "applicantName": "David",
         "accNumberCode":"DA(887"
        }
        GET index/_search
        {
          "query": {
            "match": {
              "companyName": "CA"
            }
          }
        }

'now the search response should be like this'

         "hits": [
                {
                    "_index": "shakespeare",
                    "_type": "line",
                    "_id": "63098",
                    "_score": 1,
                    "_source": {
                       "companyName": "CA",
                      "applicantName": "David",
                    "accNumberCode":"DA(887"
                    }
                }

'but I am getting like this'

        "hits": [
                    {
                        "_index": "company",
                        "_type": "line",
                        "_id": "63098",
                        "_score": 1,
                        "_source": {
                           "companyname": "CA",
                          "applicantname": "David",
                        "accnumbercode":"DA(887"
                        }
                    }

here I am getting companyname in hits but i want companyName

What version of elasticsearch are you using?

Hmmm I am not see that, field names are case sensitive in elasticsearch.

DELETE index

PUT index/_doc/1
{
  "companyName": "CA",
  "applicantName": "David",
  "accNumberCode": "DA(887"
}

PUT index/_doc/2
{
  "companyname": "CA",
  "applicantname": "Steve",
  "accnumbercode": "DA(999"
}

Then

GET index/_search
{
  "query": {
    "match": {
      "companyName": "CA"
    }
  }
}

Results

"hits" : [
  {
    "_index" : "index",
    "_type" : "_doc",
    "_id" : "1",
    "_score" : 0.2876821,
    "_source" : {
      "companyName" : "CA",
      "applicantName" : "David",
      "accNumberCode" : "DA(887"
    }
  }
]

Then

GET index/_search
{
  "query": {
    "match": {
      "companyname": "CA"
    }
  }
}

Results

"hits" : [
  {
    "_index" : "index",
    "_type" : "_doc",
    "_id" : "2",
    "_score" : 0.2876821,
    "_source" : {
      "companyname" : "CA",
      "applicantname" : "Steve",
      "accnumbercode" : "DA(999"
    }
  }
]

If you repeat exactly above do you get the same results?

And here is a discussion on this

Hi ,
I am using  7.3.2 version of ES and I am indexing data using Logstash 7.3.2 with     lowercase_column_names => false as property

and the data in index is like eg: "companyName" : "CA" 
 but in search response I am getting   "companyname" : "CA"  in hits

Hi I am happy to help but I need more info if you want help. I am asking certain questions to help diagnose.

Did you repeat my experiment? Did you get the same results? This helps set a baseline.

Can you please provide the mapping? of your index... please provide that.

I can not help if you do not provide the mapping... also only format the code not your explanation.

GET index/

Perhaps the difference between a _source and the actual stored fields this often causes confusion.

HI,

sorry for sharing confusing and less information.

 **Did you repeat my experiment? Did you get the same results? This helps set a baseline.**

 no  as I am indexing data using logstash .so I went this approach.

**Can you please provide the mapping? of your index... please provide that.**

I am not using any mapping file while indexing ,want to index DB data directly to ES

Here is my sample config file .

    input {
      jdbc { 
        jdbc_connection_string => "jdbc:mysql://localhost:3306/testdb"
        # The user we wish to execute our statement as
        jdbc_user => "root"
        jdbc_password => "123456"
        # The path to our downloaded jdbc driver
        jdbc_driver_library => "/home/comp/Downloads/mysql-connector-java-5.1.38.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        # our query
       lowercase_column_names => false
        statement => "SELECT * FROM testtable"
        }
      }
    output {
      stdout { codec => json_lines }
      elasticsearch {
      "hosts" => "localhost:9200"
      "index" => "test-migrate"
          }
    }

my table table looks  like this 

 id       companyname                  applicantName             accNumberCode
21       CA                                       DAVID                                 DA887
22      CA                                        Kevin                                   KE888

I am getting  like this in response 
{
  "_index": "test-migrate",
  "_type": "_doc",
  "_id": "21",
  "_score": 1,
  "_source": {
     "companyname" : "CA",
      "applicantname" : "David",
      "accnumbercode" : "DA(887"
    "@version": "1",
    "@timestamp": "2016-07-10T10:36:43.685Z"
  }
}

Please do not indent your text as it appears as code and makes your post hard to read.

You can edit your post to make it readable.

Thanks.

Every index in elasticsearch has a mapping / schema whether you manually created or elastic creates for you automatically.

That is a fundamental piece of elasticsearch capability.

So please run the query belowI asked after you load the data we will be able to see what the mapping looks like inside.

GET test-migrate/

Also I see you have

stdout { codec => json_lines }

Can you please provide what that looks like, we do not have enough information to help and you will not do what we ask.

I would really like to help with this but cannot help anymore if you do not provide these 2 items .. the mapping and the stdout output.

Good luck!

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