I have custom index file created and added index rule for text property. if my search key match in href tag value present under the text value the result not display. i have tried to add href index rule also with value href.. But same issue matching result not display.
my search key value:national
my sample text value:
<p><a id="back-to-forms-link" style="display: none;" href="/content/national.html" target="_self">Back to forms</a></p>
</ul>
</ul>
</p>
my index rule:
<text
jcr:primaryType="nt:unstructured"
name="text"
nodeScopeIndex="{Boolean}true"
propertyIndex="{Boolean}true"
type="String"
useInSpellcheck="{Boolean}true"
useInSuggest="{Boolean}false"/>
<href
jcr:primaryType="nt:unstructured"
name="href"
nodeScopeIndex="{Boolean}true"
propertyIndex="{Boolean}true"
type="String"
useInSpellcheck="{Boolean}true"
useInSuggest="{Boolean}false"/>
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Mohanasundaram,
Adding a rule named href won’t help - href isn’t a JCR property on your node; it’s an HTML attribute inside the text string. Oak indexes JCR properties, not HTML attributes. So you must either search/index the text property correctly, or store the URL in its own property and index that.
See below 1 options
1. Keep HTML in text and make full-text work
Query with full-text (not equality):
CONTAINS(text, 'national') (JCR-SQL2) or QueryBuilder fulltext=national.
In your index:
Put the rule under the correct nodeType (usually nt:unstructured for components).
Ensure text is analyzed and nodeScopeIndex=true.
Avoid HTML stripping if you need attribute values: if your index has an HTMLStripCharFilter, it will drop attributes (and you’ll lose href="/content/national.html").
Reindex after changes (reindex=true once).
Minimal example (under /oak:index/yourIndex😞
indexRules
nt:unstructured
properties
text
analyzed=true
nodeScopeIndex=true
useInExcerpt=true
.
If you must extract href tokens from the HTML string, use a pattern-based token filter (e.g., PatternCaptureGroup) to capture values from href="..."—but this is advanced and depends on what’s allowed in your AEM/Oak version.
OR
2. Best practice: store link separately
Change your component to also write the URL to a dedicated property (e.g., linkURL="/content/national.html"). Then index that real property:
indexRules
nt:unstructured
properties
linkURL
propertyIndex=true
analyzed=true
Now CONTAINS(linkURL, 'national') (or equality on linkURL) will match reliably.
Hi @Mohanasundaram,
Adding a rule named href won’t help - href isn’t a JCR property on your node; it’s an HTML attribute inside the text string. Oak indexes JCR properties, not HTML attributes. So you must either search/index the text property correctly, or store the URL in its own property and index that.
See below 1 options
1. Keep HTML in text and make full-text work
Query with full-text (not equality):
CONTAINS(text, 'national') (JCR-SQL2) or QueryBuilder fulltext=national.
In your index:
Put the rule under the correct nodeType (usually nt:unstructured for components).
Ensure text is analyzed and nodeScopeIndex=true.
Avoid HTML stripping if you need attribute values: if your index has an HTMLStripCharFilter, it will drop attributes (and you’ll lose href="/content/national.html").
Reindex after changes (reindex=true once).
Minimal example (under /oak:index/yourIndex😞
indexRules
nt:unstructured
properties
text
analyzed=true
nodeScopeIndex=true
useInExcerpt=true
.
If you must extract href tokens from the HTML string, use a pattern-based token filter (e.g., PatternCaptureGroup) to capture values from href="..."—but this is advanced and depends on what’s allowed in your AEM/Oak version.
OR
2. Best practice: store link separately
Change your component to also write the URL to a dedicated property (e.g., linkURL="/content/national.html"). Then index that real property:
indexRules
nt:unstructured
properties
linkURL
propertyIndex=true
analyzed=true
Now CONTAINS(linkURL, 'national') (or equality on linkURL) will match reliably.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies