How to insert multivalued field in solr using lily

2019-09-02 15:17发布

问题:

I am trying to insert a comma-seperated string as a multivalued field to my morphline configuration from a Row-based Structure in HBase.

Can any one suggest any better way or experience I am new to this.

Is there any way I can do that.

HBase-Indexer Mapper:

<?xml version="1.0"?>
<indexer table="Document_Test"
    mapper="com.ngdata.hbaseindexer.morphline.MorphlineResultToSolrMapper"
    unique-key-field="documentId" mapping="row">

    <param name="morphlineFile" value="/path/to/morphline.conf" />

</indexer>

Morphline Conf:

{
   extractHBaseCells {
             mappings : [
                           {
                              inputColumn : "CF:DocumentId"
                              outputField : documentId
                              type : long
                              source : value
                           }
                           {
                              inputColumn : "CF:Persons"
                              outputField : persons
                              type : string
                              source : value
                           }
                        ]
                    }

      // Some command here which can be used, I tried with **java**, But didn't worked and make it a single string

}

It is just making a single string like this :

 {
    "persons": [
      "[Panos Kammenos, King Salman, Nabil Sadek, Ehab Azmy, Hesham Abdelhamid]"
    ],
    "documentId": 38900223,
    "_version_": 1535233203724353500
  }

UPDATED

Tried this one and It worked on Row-Based mappings or Tall structure.

     {
    extractHBaseCells {
        mappings : [
            {
                inputColumn : "CF:DocumentId"
                outputField : documentId
                type : long
                source : value
            }
            {
                inputColumn : "CF:Persons"
                outputField : persons
                type : string
                source : value
            }
        ]
    }
}
{
    split{
        inputField : persons
        outputField : persons_multi
        separator : ","
        isRegex : false
    }
}

回答1:

You can use split command as follows:

{
    extractHBaseCells {
        mappings : [
            {
                inputColumn : "CF:DocumentId"
                outputField : documentId
                type : long
                source : value
            }
            {
                inputColumn : "CF:Persons"
                outputField : persons
                type : string
                source : value
            }
        ]
    }
}
{
    split{
        inputField : persons
        outputField : persons_multi
        separator : ","
        isRegex : false
    }
}

Let me know if you encounter any problem.