I have an indexed multi-value field. If I add a parallel multi-value field, is it reliable to have the same order?
Consider this CSV and separator |
:
ID,Name,Number
988,Sixth|Second|Third,6|2|3
989,Fifth|Fourth|First,5|4|1
If I get the records by id
(not search), can I be sure that the arrays of two fields are always in the original matching order?
{
"doc":
{
"ID":988,
"Name":["Sixth",
"Second",
"Third"]},
"Number":[6,
2,
3]}}
Yes, the order is deterministic and stable. You can safely assume that the sequence of multivalued fields is kept intact. The post detailing this on the mailing list has since disappeared.
There is no guarantee about the ordering of the fields - i.e. "Number" can come before "Name", but internally in the field (the mulivalued part) the values will be returned in the same order as they were indexed.
We've been running applications on Solr since 2008 that depend on this behavior and it has never been an issue.
If there's many fields where you need to know that [0] in one field corresponds to [0] in another field, etc., it might be more useful to add a stored only (not indexed, etc.) JSON representation of the structure as a field and just index the other fields (and not store them) to make the application level code simpler.