Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-6020

Auto-generate a unique key in schema-less mode if data does not have an "id" field


    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.10, 6.0
    • Component/s: Schema and Analysis
    • Labels:


      Currently it is not possible to use the schema-less example if my data does not have an "id" field.

      I was indexing data where the unique field name was "url" in schema-less mode. This requires one to first change unique key name in the schema and then start solr and then index docs. If one had already started solr, one'd first need to remove managed-schema, rename schema.xml.bak to schema.xml and then make the necessary changes in schema.xml. I don't think we should fail on such simple things.

      Here's what I propose:

      1. We remove "id" and uniqueKey from the managed schema example
      2. If there's a field named "id" in the document, we use that as the uniqueKey
      3. Else we fallback on generating a UUID or a signature field via an update processor and store it as the unique key field. We can name it as "id" or "_id"
      4. But if a uniqueKey is already present in original schema.xml then we should expect the incoming data to have that field and we should preserve the current behavior of failing loudly.


        1. SOLR-6020.patch
          12 kB
          Shalin Shekhar Mangar
        2. SOLR-6020.patch
          12 kB
          Shalin Shekhar Mangar
        3. SOLR-6020.patch
          11 kB
          Shalin Shekhar Mangar
        4. SOLR-6020.patch
          38 kB
          Vitaliy Zhovtyuk



            • Assignee:
              shalinmangar Shalin Shekhar Mangar
              shalinmangar Shalin Shekhar Mangar
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: