Search code examples
solrwebsphere-commerce

Solr to query the last index of array


Query the last index field in Solr Array.

Below is the solr document for one product has the parentCatgroup_id_search as the attribute field

<arr name="parentCatgroup_id_search">
<str>10001_14533</str>
<str>10001_14501</str>
<str>10001_14502</str>
<str>20051_15060</str>
<str>20051_15096</str>
<str>20051_15121</str>
<str>20051_15144</str>
</arr>

is there any way to query all the documents matches '20051_15144' as the last index of parentCatgroup_id_search.


Solution

  • No, there is no built-in support for querying a specific index in a multi valued field.

    If this is a specific requirement for your application, you should index the last value as a separate field - i.e. parentCatgroup_id_search_last. If you need to search by index, as well as last or first, create a second field where you prefix the values with their indices and any aliases you need - for example last:20051_15144.