What is the use of “multiValued” field type in Solr?

后端 未结 3 1249
盖世英雄少女心
盖世英雄少女心 2020-11-27 15:43

I\'m new to Apache Solr. Even after reading the documentation part, I\'m finding it difficult to clearly understand the functionality and use of the multiValued

3条回答
  •  孤城傲影
    2020-11-27 16:00

    multiValued defined in the schema whether the field is allowed to have more than one value.

    For instance:
    if I have a fieldType called ID which is multiValued=false indexing a document such as this:

    doc {
      id : [ 1, 2]
      ...
    }
    

    would cause an exception to be thrown in the indexing thread and the document will not be indexed (schema validation will fail).

    On the other hand if I do have multiple values for a field I would want to set multiValued=true in order to guarantee that indexing is done correctly, for example:

    doc {
      id : 1
      keywords: [ hello, world ]
      ...
    }
    

    In this case you would define "keywords" as a multiValued field.

提交回复
热议问题