Search for tags

Hello forum,

recently, I started working with XWiki and came across a question I couldn’t resolve by searching for an answer in the documentation:
Is there a way to search for a tag I added to a page?

So I have quite a lot of pages with a couple of nested pages and all have different tags assigned to it. And I’d like to search my entire Wiki for a specific tag.

Thanks for your answers!

Maybe this can help: http://extensions.xwiki.org/xwiki/bin/view/Extension/Tag%20Application

If you’re referring to SOLR search, I see some info at http://extensions.xwiki.org/xwiki/bin/view/Extension/Solr%20Search%20Application#HFacetingonObjectProperties

I don’t know if it’s a feature OOB or if you need to enable it.

Thank you for your quick response.

I already came across the two links you posted, but that is not what I’m searching for.
Creating tags, editing tags and viewing all tags existing in my Wiki is working fine.
But I’m looking for the possibility to search for a tag and get a list of pages with it assigned to in a user friendly way i.e. I don’t want to have to deal with code.

Well my two links explain what you mentioned…

  • First one explains how to go to a tag and see all pages tagged with it.
  • Second one explains how to configure the search to add a facet for filter by tags

Ah here’s another one: you can search for xobject in xwiki and since tags are objects you can search for them.

According to http://design.xwiki.org/xwiki/bin/view/Design/SolrSchema the following should work but it didn’t for me:

object.XWiki.TagClass:vma

(where “vma” is the name of a tag)

Maybe @mflorea knows more.

Sorry, then I got something wrong.

I’ll look into it, thank you.

I don’t quite like the overview of all my tags, since I have quite a lot.

Edit:
The Solr search application shows me, that I can add a new “search index”, if I’m getting this right? But I don’t get how to add this new index.

XWiki already has a search function. Everything I need, is to be able to get results when searching for a tag. These results should be the pages tagged with the tag I searched for.

Hi,

I have same question in https://forum.xwiki.org/t/question-about-solr-search-and-pages-priority/1129/5

I want to add weight to tag in search (for example, pages where tag with search word occurs will be higher in the search results). I think it may help (but my topic in progress).

update: In you case may be help add filter to search (if u want search only in tags and not in page title, descrition and etc)

This worked for me for Search Suggestions:

fq=type:DOCUMENT
qf=property.XWiki.TagClass.tags

Hey everybody!

I tried this

fq=type:DOCUMENT
qf=property.XWiki.TagClass.tags

but it dosn’t work AFAIK. What to do? I really would like to add the tags in the search suggestions :slight_smile:

Thank you!

Vince

This works fine for me. Maybe you didn’t activate the search suggest source, there’s a checkbox.

Hey mflorea!
thank you for your reply. The search suggest source is activated as far as I know.
Here is my complete config, could you have a look, maybe I did something wrong somewhere.

Selection_007

Do I need a xwiki restart to get it to work?

Oh, I don’t know why, but it works now! thank you!! :slight_smile:

@mflorea This works for me, too. However, suggestions from tag contents are only made if the search query respects capitalization in tags. That’s not what I want. Do I need all the tags to be lowercase?

The tags are stored using a Static List xobject property whose value is indexed in Solr as a “string”. This means the tags are not tokenized or analyzed in any way. They are indexed as is (i.e. a single token with the tag value), in order to help with exact matching. So yes, if you need free text search to match the tags then you need to use lowercase tags, and the user must search lowercase.

The alternative is to modify Solr’s managed-schema file to copy the property.XWiki.TagClass.tags_string field into another field that is indexed lowercase. Check for instance How to create a case insensitive copy of a string field in SOLR? - Stack Overflow .

1 Like

Thanks, @mflorea. Well, we are no Solr experts. How would we have to do that and will changes in managed-schema be overwritten with the next upgrade of XWiki?

Well, I think, we figured it out. Added the follwing lines to managed-schema:

<field name="tag" type="text_general" indexed="true" stored="true" multiValued="true" />

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

and adjusted the page SolrSearchConfig in XWiki to use this new field with an appropriate weight:
'queryFields': { 'DOCUMENT': 'title^10.0 name^10.0 tag^5

The query in the correspondig tag source in Search Suggest in the XWiki admin section must be set, accordingly, to:

fq=type:DOCUMENT
qf=tag

image

Now the search for tags is case-insensitive.

1 Like

I don’t think so. @tmortagne can you confirm? Thanks.

1 Like

The Solr search core configuration is automatically reseted every time there is a change in the standard one or every time the version of the embedded Solr instance is upgraded (which pretty much always imply a change in the configuration), so I would really not recommend modifying it directly. Last time we did something that cause this core to be reseted was in 14.8, but it could happen any time (for example we will mosty probably upgrade to Solr 9.x in XWiki 15.x).

@tmortagne How could we configure this indirectly? Any hint?

Honestly, while I worked a lot on low level Solr core integration in XWiki @mflorea is much more knowledgeable than me on how to query this specific core.

At worst, I guess you could simply have a process to make sure your customization are there after each upgrade (XWiki is not going to reset this core out of the blue, that’s only an upgrade thing).

One trick I use in Solr Security (XWiki.org) (which inject custom metadata for each document in the search core) is to programmatically make sure the schema contains what I need using the Solr API.

1 Like