Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9138807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:18:18+00:00 2026-06-17T09:18:18+00:00

I need a tag based search system by JCR like Modeshape. i want to

  • 0

I need a tag based search system by JCR like Modeshape. i want to search nodes by some tags.
Question is that what is the best way to implement it?

  1. Adding new node type and mixins for tags
    so if that is true, where can i define my tags name that is viewable to users?
  2. Implement a hierarchy of tags and reference them in my nodes.
    so if that is true how can i reference them?
  3. Any other way.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:18:19+00:00Added an answer on June 17, 2026 at 9:18 am

    There are several ways to implement tags in JCR. Which option you pick will depend upon the needs of your own application(s). Here are four options I know of.

    Option 1: Use Mixins

    Define for each tag a mixin node type definition that is a marker mixin (it has no property definitions or child node definitions), registering them dynamically using the NodeTypeManager. Then when you want to “tag” a node, simply add to that node the mixin that represents the tag. Any node could have multiple tags, and you could query for all the nodes that have a particular tag.

    (In the rest of this response, “acme” is used as a generic namespace. You should replace this with a namespace suitable for your own application and organization.)

    For example, given a tag “acme:tag1”, you could find all nodes that have this tag with the simple query:

    SELECT * FROM [acme:tag1]
    

    The disadvantage of this approach is that maintaining tags is cumbersome. Creating new tags requires registering new node types. You cannot easily rename tags, but instead would have to create the mixin for the tag with the new name; find all nodes that have the mixin representing the old tag, remove the old mixin, and add the new one; and finally remove the node type definition for the old tag (after it is no longer used anywhere). Removing old tags is done in a similar manner. Another disadvantage is that it is not easy to associate additional metadata (e.g., display name) with a tag, since extra properties aren’t allowed on node type definitions.

    This approach should perform quite well.

    Option 2: Use a taxonomy and strong references

    In this approach, you would create a simple node structure in an area of the repository into which you can create a node for each tag (e.g., a taxonomy). On this node you could set properties that describe the tag (e.g., display name); these properties can be changed at any time (e.g., to rename the tag).

    Then to “apply” the tag to a node, you simply have to create some sort of relationship to the tag. One way is to define a mixin node type that contains a “acme:tags” multivalued property of type REFERENCE. When you want to apply one or more tags to a node, simply add the mixin to the node and set the “acme:tags” property to the tag node(s).

    To find all nodes of a particular tag, you can call “getReferences()” on a tag node to find all of the nodes that contain a reference to the tag node.

    This approach has the benefit that all tags have to be controlled/managed within one or more taxonomies (including perhaps user-specific taxonomies). However, there are some disadvantages, too. First and foremost, the performance of REFERENCE properties might not be great. Some JCR implementations discourage the use of REFERENCES altogether. ModeShape does not, but ModeShape might start to degrade REFERENCE performance when there are lots of nodes that contain references to the same node (e.g., lots of nodes with a single tag).

    Option 3: Use taxonomy and weak references

    This option is a hybrid similar to Option 2 above except that the “acme:tags” properties would be WEAKREFERENCE instead of REFERENCE. You would still define and manage one or more taxonomies. To find nodes with a particular tag, you can’t use the “getReferences()” method on the tag node (since they don’t work with WEAKREFERENCE properties), but you can easily do this with a query:

    SELECT * FROM [acme:taggable] AS taggable 
    JOIN [acme:tag] AS tag ON taggable.[acme:tags] = tag.[jcr:uuid]
    AND LOCALNAME(tag) = 'tag1'
    

    This approach does enforce using one or more taxonomies, makes it a bit easier to control the tags, since they must exist in a taxonomy before they can be used. Renaming and removing is also easier. Performance-wise, this is better than the REFERENCE approach, since WEAKREFERENCE properties will perform better with large numbers of references, regardless of whether they all point to one node or many.

    The disadvantage is that you can remove a tag even if it is still used, but the nodes that contain a WEAKREFERENCE to that removed tag will not be valid anymore. This can be remedied with some conventions in your application, or by simply using metadata on the taxonomy to say that a particular tag is “deprecated” and shouldn’t be used. (IMO, the latter is actually a benefit of this approach.)

    This option will generally perform and scale much better than Option 2.

    Option 4: Use string properties

    Yet another approach is to simply use a STRING property to tag each node with the name of the tag(s) that are to be applied. For example, you could define a mixin (e.g., “acme:taggable”) that defines a multi-valued STRING property, and when you want to tag a node simply add the mixin (if not already present) and add the name of the tag as a value on the “acme:tags” STRING property (again, if it’s not already present as a value).

    The primary advantage of this approach is that it is very simple: you’re simply using string values on the node that is to be tagged. To find all nodes that are tagged with a particular tag (e.g., “tag1”), simply issue a query:

    SELECT * 
    FROM [acme:taggable] AS taggable 
    WHERE taggable.[acme:tags] = 'tag1'
    

    Management of the tags is easy: there is no management. If a tag is to be renamed, then you could rename the tag values. If a tag is to be deleted (and removed from the nodes that are tagged with it), then that can be done by removing the values from the “acme:tags” properties (perhaps in a background job).

    Note that this allows any tag name to be used, and thus works best for cases where the tag names are not controlled at all. If you want to control the list of strings used as tag values, simply create a taxonomy in the repository (as described in Options 2 and 3 above) and have your application limit the values to those in the taxonomy. You can even have multiple taxonomies, some of which are perhaps user-specific. But this approach doesn’t have quite the same control as Options 2 or 3.

    This option will perform a bit better than Option 3 (since the queries are simpler), but will scale just as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a tag cloud based on tags I assign to products.
I want to write a tag based search engine in MySQL, but I don't
I need to access a components tag attribute like: <h:inputtext id=input_age/> from a backing
I working on a tag based search. I have three tables tag(id,name), tagXmedia(id,tag_id,media_id), and
I need to do a search based on a term entered into a text
I need some help in bison grammar construction. From my another question: I'm trying
I am currently creating a tag cloud that currently displays the tag based on
I have some markup like this: <div class=field> <div class=selector id=uniform-blablabla> [select tag markup]
A product belogs_to category. A category has_many products I need a select tag that
I need to make a custom filter on productCollection based on a specific tag.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.