Column name case changes from camel case to lowercase, when we import data to elastic from SQL DB


(Abhijit Shivathare) #1

SQL DB Column names are Id , FirstName , LastName.
When we imported data to elastic Search , the column name are changes to id, firstname , lastname.

Is there any solution to keep column name as its?


(Mark Walkom) #2

You need to do that in the mapping of the fields, you can either set them to not_analyzed or create your own analysis chain without the lower case analyzer.


(Abhijit Shivathare) #3

Thanks for your replay.
Can you please give me reference URLs.


(Magnus Bäck) #4

How are you importing the data?

Mark's comment about field mapping applies to the value of the fields but not the name of the fields.


(Abhijit Shivathare) #5

we are importing data using Nest.
We have created the C# utility to import data . we read data from SQL DB and import as object into elastic search

        Uri ESUrl = new Uri(URL);
        string IndexArry = "discussions,discussion";
        var settings = new ConnectionSettings(ESUrl);
        var client = new ElasticClient(settings);

        try
        {
            var request = new BulkDescriptor();
            string[] IndexType = IndexArry.Split(',');
            if (IndexType.Count() > 1)
            {
                foreach (sqlDBData item in contentItems)
                {
                    request.Index<sqlDBData>(op => op
                            .Index(IndexType[0])
                            .Type(IndexType[1])
                            .Id(item.Id)
                            .Document(item)
                            );

                }
                var result = client.Bulk(request);
            }
        catch (Exception e)
        {
            string m = e.Message;
            // can do this logging thing.
        }

(Abhijit Shivathare) #6

we have used Nest.dll for import the data into elastic search in C#
Uri ESUrl = new Uri(URL);
string IndexArry = "discussions,discussion";
var settings = new ConnectionSettings(ESUrl);
var client = new ElasticClient(settings);

        try
        {
            var request = new BulkDescriptor();
            string[] IndexType = IndexArry.Split(',');
            if (IndexType.Count() > 1)
            {
                foreach (DiscussionDbDetails item in contentItems)
                {
                    request.Index<DiscussionDbDetails>(op => op
                            .Index(IndexType[0])
                            .Type(IndexType[1])
                            .Id(item.Id)
                            .Document(item)
                            );

                }
                var result = client.Bulk(request);
            }
        }
        catch (Exception e)
        {
            string m = e.Message;
            // can do this logging thing.
        }

(Magnus Bäck) #7

I doubt the Nest client does the down-casing of the field names. Have you double-checked that the down-casing doesn't take place when DiscussionDbDetails objects are serialized to JSON?


(Abhijit Shivathare) #8

I have cross check the Document in request which is pass to bulk insert , object is not down-casing.
var result = client.Bulk(request)
((Nest.BulkIndexDescriptor<ESConnecter.DiscussionDbDetails>)((new System.Collections.Generic.Mscorlib_CollectionDebugView<Nest.IBulkOperation>(((System.Collections.Generic.SynchronizedCollection<Nest.IBulkOperation>)(request.Nest.IBulkRequest.Operations)).items)).Items[0])).Nest.IIndexOperation.Document


(Magnus Bäck) #9

That screenshot only proves that the original member names are mixed case. Anyway, this seems to be an issue with Nest after all:


(system) #10