SolrSearch: How to make tags/search for tags case insensitive

Hi.

Nearly all parameters to search for are case insensitive. But not tags. A tag “Example” isn’t found if searched for “example”.

Any idea how to change that behaviour?

Regards, Simpel

same problem! is there any solution?

Hi,

You can’t force case-insensitive search from the search query. The way the search query is analyzed and matched against a field from the Solr index is determined by the field type. In other words the search results depend very much on the way the data is indexed. The page tags are stored using a Static List property (of the XWiki.TagClass). Static List property values are currently indexed as strings, which means no transformation is performed. Each tag ends up as a token in the Solr index. See:

The field name is property.XWiki.TagClass.tags_string. The _string suffix triggers the string indexing, see https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-15.8/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-server/xwiki-platform-search-solr-server-core/src/main/resources/conf/managed-schema#L271 .

What options do you have? The simplest is probably to create another Solr field that indexes the same information (page tags) differently. You can do this from the Solr schema:

<copyField source="property.XWiki.TagClass.tags_string" dest="property.XWiki.TagClass.tags_sortString" />

This creates a new property.XWiki.TagClass.tags_sortString field that indexes the page tags as “sortString” which is defined here https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-15.8/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-server/xwiki-platform-search-solr-server-core/src/main/resources/conf/managed-schema#L286C27-L286C37 and seems to do what you want https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-15.8/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-server/xwiki-platform-search-solr-server-core/src/main/resources/conf/managed-schema#L624

lowercases the entire field value, keeping it as a single token.

Of course, you have to re-index you wiki after customizing the Solr schema.

Hope this helps,
Marius

@mflorea: I think we have a product issue here, as other tags-related APIs are case-insensitive, to my knowledge.

So the concept of tag in XWiki is case-insensitive, thus search should probably also be case insensitive by default for tags.

However, I don’t think all of the tag APIs are case-insensitive, so there is a bit of a mess here…

Anca

1 Like