简体   繁体   English

Solr-多值字符串字段和具有多值的单值字符串之间有什么区别?

[英]Solr - what is the difference between multivalued string field and single valued string with multi values?

If I need to index a set of values under a single field name, should I use multivalued field or should I use a singlevalued field and have all the values in this field seperated by a whitespace? 如果需要在单个字段名称下为一组值建立索引,我应该使用多值字段还是应该使用单值字段并使该字段中的所有值都由空格分隔?

the field type is string. 字段类型为字符串。

thanks. 谢谢。

you can think of multivalued field as an array or a list... and for your question it depends what kind of operations will you run on that field. 您可以将多值字段视为数组或列表...,对于您的问题,这取决于您将对该字段执行哪种操作。

if you will keep adding some stuff to that field frequently, you should go with multivalued field. 如果您将经常向该字段中添加一些内容,则应使用多值字段。 instead of setting single string field each time you get a new item to add, you can simply add it to the multivalued field. 您不必每次都添加一个新项目来设置单个字符串字段,只需将其添加到多值字段即可。 Also if you multivalued field, you wont need to know the whole list while updating it. 同样,如果您使用多值字段,则在更新列表时无需了解整个列表。 but for a single field, you need to know the old values in it.. 但是对于单个字段,您需要知道其中的旧值。

to make it more clear; 使其更清楚;

lets say that you need to index "aaa bbb ccc".. if you put them into single field it will be something like 假设您需要索引“ aaa bbb ccc” ..如果将它们放在单个字段中,它将类似于

<str>aaa bbb ccc</str>

and if you need add ddd to this field, then you need to add aaa bbb ccc ddd to the field actually (I asssume you wouldnt want to check the old values of the field each time you are updating it) 并且如果需要在此字段中添加ddd,则实际上需要在该字段中添加aaa bbb ccc ddd(我假设您不想在每次更新时都检查该字段的旧值)

but if you go with multivalued field, for aaa bbb ccc it will be something like 但是如果您使用多值字段,对于aaa bbb ccc它将是类似

<field><str>aaa</str><str>bbb</str><str>ccc</str></field>

for this case, when you need to add ddd, you dont have to know the old values, just add ddd and you are done... 对于这种情况,当您需要添加ddd时,您不必知道旧值,只需添加ddd就可以了。

but if there will be removals from the field too, you should go with single field, as solr doesnt support deletions from a multivalued field (though you can do it with ease by hacking the source code ) 但是如果字段中也有删除项,则应该使用单个字段,因为solr不支持从多值字段中删除(尽管您可以通过修改源代码轻松实现)

i hope it helps... as the information you have given is some kinda too little to have a clear answer 我希望能对您有所帮助...因为您所提供的信息太少了,无法给出清晰的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM