Expand my Community achievements bar.

SOLVED

Lucene Index with Multiple Properties

Avatar

Level 3

I need to create a search index to address the traversing errors in error.log. Specifically:
.../* xpath: /jcr:root/content/solutions//*[(jcr:content/@page-category = 'category:news')] */, path=/content/solutions//*, property=[jcr:content/page-category=[category:news]]); consider creating an index or changing the query
.../* xpath: /jcr:root/content/solutions/en/stories//*[(jcr:content/@author = '/content/solutions/en/author/dan')] */, path=/content/solutions/en/stories//*, property=[jcr:content/author=[/content/solutions/en/author/dan]]); consider creating an index or changing the query
.../* xpath: /jcr:root/content/solutions//*[(jcr:content/@series = 'Press Releases')] */, path=/content/solutions//*, property=[jcr:content/series=[Press Releases]]); consider creating an index or changing the query

So it appears I need a property index for page-category, author, and series.

Explain Query tells me the Lucene index is more performant than a standard property index. So if I used Lucene, should it be 1 index with all 3 properties or 3 separate indexes?

 

There are many out-of-the-box Lucene property indexes. But I'm not sure if they are created that way to logically separate the properties or if it serves a purpose to have them separated.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

 

yes, you can create a custom index, which contains these 3 properties.If you just do equality matches (as shown above), you don't need more settings in the index.

if you want to do work more sophisticated (e.g.  fulltext conditions) I recommend you to check the JCR Query Cheatsheet for AEM [1].

 

 

[1]: https://experienceleague.adobe.com/docs/experience-manager-65/assets/JCR_query_cheatsheet-v1.0.pdf?l...

View solution in original post

10 Replies

Avatar

Correct answer by
Employee Advisor

Hi,

 

yes, you can create a custom index, which contains these 3 properties.If you just do equality matches (as shown above), you don't need more settings in the index.

if you want to do work more sophisticated (e.g.  fulltext conditions) I recommend you to check the JCR Query Cheatsheet for AEM [1].

 

 

[1]: https://experienceleague.adobe.com/docs/experience-manager-65/assets/JCR_query_cheatsheet-v1.0.pdf?l...

Avatar

Level 3

So I had opened a support ticket prior to this post and didn't get a satisfactory answer, which is why I posted here.  However, eventually I got this response:

 

"If you have one index for all properties it will index all nodes that contain one of the properties, which can make the query less efficient. It is only recommended to use a single index when all of the properties being indexed are related to allow Lucene to evaluate as many property restrictions as possible natively."

 

What do you think?

Avatar

Level 3

Hi @Jörg_Hoh

The linked cheat sheet is a great document -- very nicely organized, clear examples -- but it is no longer accessible. Do you mind to repost it somewhere so we can save it?

Avatar

Employee Advisor

We updated the document into a version 1.1. Please bookmark this page where the latest version is always referenced:

https://www.adobe.com/go/aem_jcr_query_cheat_sheet

 

Avatar

Employee Advisor

I have executed below three xpath queries using Oak Index definition generator to understand few things like type lucene, property index will be true or not as shown below -

 

DEBAL_DAS_0-1646381356946.pngDEBAL_DAS_1-1646381393824.pngDEBAL_DAS_2-1646381445229.png

From these structure I have understood we could create index with all 3 properties then it will help you -

 

DEBAL_DAS_0-1646393423517.png

 

@Jörg_Hoh , please correct me also.

 

 

 

 

 

 

 

Avatar

Employee Advisor

Yes, you can merge all of these 3 indexes into a single index.

Avatar

Level 3

I know it's been a while, but I did want to close this out.  Turns out all three properties were related to the same nodes/pages so a single index did indeed work, like you have @DEBAL_DAS.   This is what mine looks like:

image001.png

If you were deploying via package, this is the entry that would go in /jcr_root/_oak_index/.content.xml:

<myappLucenePropertyIndexArticleMultimediaPages jcr:primaryType="oak:QueryIndexDefinition" type="lucene" includePropertyNames="[author,page-category,series]" fulltextEnabled="{Boolean}false" async="async"/>