You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Marcel Reutegger <ma...@gmx.net> on 2009/06/02 12:05:03 UTC
Re: Controlling the Lucene indexing
Hi,
On Wed, May 20, 2009 at 21:54, Bernd Fondermann <bf...@brainlounge.de> wrote:
> Alexander Klimetschek wrote:
>> On Wed, May 20, 2009 at 5:29 AM, Bernd Fondermann <bf...@brainlounge.de> wrote:
>>> Is it possible to control for the built-in Lucene indexing how
>>> Jackrabbit Nodes are indexed with respect to how Attributes are mapped
>>> to Lucene Fields and when Storing, Indexing and Tokenizing is applied?
>>
>> Have a look at
>>
>> http://wiki.apache.org/jackrabbit/Search
>>
>> There are some things to configure, for example you can provide a
>> different Lucene analyzer ("analyzer" parameter).
>
> Yes, I was already aware of that page. I browsed the Jackrabbit code,
> too. But I don't see that controlling per-Attribute indexing is
> possible, is it?
I'm not sure what exactly you want to control, but the indexing
configuration [0] allows you to tweak some of the indexing behaviour.
regards
marcel
[0] http://wiki.apache.org/jackrabbit/IndexingConfiguration
Re: Controlling the Lucene indexing
Posted by Ard Schrijvers <a....@onehippo.com>.
On Wed, Jun 10, 2009 at 12:13 PM, Alexander Klimetschek<ak...@day.com> wrote:
> On Wed, Jun 10, 2009 at 9:45 AM, Bernd Fondermann<bf...@brainlounge.de> wrote:
>>> i.e. create a regular JCR property instead of creating this
>>> low-level-behind-the-scences fields in lucene. then run the more
>>> sophisticated searches on those additional properties.
>>
>> How could that work? I could not differentiate using Lucene query field
>> qualifiers.
>
> For any additional metadata you want to search for, you compute it in
> your application (on write or in an observation listener) and put it
> into separate properties. These can then be used in your normal JCR
> Xpath or SQL search. This might not enable all advanced indexing
> features you can do with a plain Lucene, but should still cover a lot.
> And adding additional properties in JCR is fine - it's more about
> de-normalization than what you are typically taught with relational
> databases.
I think there are different camps in this, as also within my
direct Colleagues we have different favors: IMO, it feels natural to
index a property possibly in multiple ways, to index a date property
multiple times with different granularity etc etc. It is meant for
searching only, and I think anybody accustomed to something like Solr
does it all the time. The other camp seems to favor always adding
just a property with some mangled values (date with granularity on
day).
As for efficient searching, you inevitable have some content
duplication, I'd favor this duplication in the lucene index only, and
not in the persisting layer.
Regards Ard
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
Re: Controlling the Lucene indexing
Posted by Ard Schrijvers <a....@onehippo.com>.
On Wed, Jun 10, 2009 at 12:13 PM, Alexander Klimetschek<ak...@day.com> wrote:
> On Wed, Jun 10, 2009 at 9:45 AM, Bernd Fondermann<bf...@brainlounge.de> wrote:
>>> i.e. create a regular JCR property instead of creating this
>>> low-level-behind-the-scences fields in lucene. then run the more
>>> sophisticated searches on those additional properties.
>>
>> How could that work? I could not differentiate using Lucene query field
>> qualifiers.
>
> For any additional metadata you want to search for, you compute it in
> your application (on write or in an observation listener) and put it
> into separate properties. These can then be used in your normal JCR
> Xpath or SQL search. This might not enable all advanced indexing
Hmmm, I think there are different camps in this, as also within my
direct Colleagues we have different favors: IMO, it feels natural to
index a property possibly in multiple ways, to index a date property
multiple times with different granularity etc etc. It is meant for
searching only, and I think anybody accustomed to something like Solr
does it all the time. The other camp seems to favor always adding
just a property with some mangled values (date with granularity on
day).
As for efficient searching, you inevitable have some content
duplication, I'd favor this duplication in the lucene index only, and
not in the persisting layer.
Regards Ard
> features you can do with a plain Lucene, but should still cover a lot.
> And adding additional properties in JCR is fine - it's more about
> de-normalization than what you are typically taught with relational
> databases.
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
Re: Controlling the Lucene indexing
Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Jun 10, 2009 at 9:45 AM, Bernd Fondermann<bf...@brainlounge.de> wrote:
>> i.e. create a regular JCR property instead of creating this
>> low-level-behind-the-scences fields in lucene. then run the more
>> sophisticated searches on those additional properties.
>
> How could that work? I could not differentiate using Lucene query field
> qualifiers.
For any additional metadata you want to search for, you compute it in
your application (on write or in an observation listener) and put it
into separate properties. These can then be used in your normal JCR
Xpath or SQL search. This might not enable all advanced indexing
features you can do with a plain Lucene, but should still cover a lot.
And adding additional properties in JCR is fine - it's more about
de-normalization than what you are typically taught with relational
databases.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: Controlling the Lucene indexing
Posted by Ard Schrijvers <a....@onehippo.com>.
Hello,
> Feature-downgrading doesn't help me. I have a clear need how nodes must
> be indexed. Since there seems to be no easy way to do this in
> Jackrabbit, so I fall back to my own index.
> And that's ok for me. I just asked (although I looked at the code) to
> not miss something.
>
> Thanks for all your patience and help!
Sry for dropping in so late, I have been to occupied lately to even
follow the list. Hope to have more time in near future. Anyways, my 2
cents about this:
First of all, I wouldn't go for a seperate lucene index and keep it in sync.
I would favor support for more indexing tuning within
Jackrabbit. I think everybody accustomed to lucene, or Solr, is used
to define *how* fields should be indexed. Now, we have quite some
support for this in JackRabbit already, see [1], but some tuning is
missing (for example I would like to be able to indicate that lucene
should not index some property (summary) as a single term, as I never
want to sort on it, or use equals for it....)
As you can find at the buttom of [1], you can configure a *per*
property analyzer. So, if I know I have some comma seperate keywords
property, I could configure the property to be indexed with my
CommaSeperatedKeyWordAnalyzer. So basically, support for it is there.
Now, what is not currently easy to achieve is for example indexing one
and the same property in multiple ways: If for example I am indexing a
title property, I might also want to index a short_title (which is not
a jcr property, just index field only) : now, if I have 1.000.000 text
documents having a title, I could still do a sort on short_title,
whereas sorting on the normal title field will result in instant OOM
(I am actually facing this, and will use some kind of 'short_title'
strategy...where similar stuff applies for date range queries wrt
different granularities)
Anyways, back to Bernd's thing:
As Marcel points out, you only need to extend the SearchIndex and
override createDocument. You can then also use your own NodeIndexer
impl which indexes all the properties (and index a single property in
multiple ways) the way you want. The only drawback that makes it a
little more difficult to write, is that for historical reasons (as it
was not possible with the lucene version used at the time of writing
the jr indexing) all properties end up in a single lucene property
field, hence, you need to do some field value prefixing tricks (not
hard, just a little annoying and confusing from time to time :-))
In your repository.xml, in the <SearchIndex> element, change for example:
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> to
<SearchIndex class=",,,..query.lucene.MySearchIndex">
Anyways, you can take look at [2] and [3] for examples, though they
are already somewhat more sophisticated as we added custom indexing
configurations as well for optimizing indexing (for example date
granularity config which I actually still need to add)
We extended the SearchIndex for indexing for example facets, to expose
faceted navigation over jcr as a virtual structure
Hope this helps
Regards Ard
[1] http://wiki.apache.org/jackrabbit/IndexingConfiguration
[2] http://svn.onehippo.org/repos/hippo/hippo-ecm/trunk/repository/engine/src/main/java/org/hippoecm/repository/query/lucene/ServicingSearchIndex.java
[3] http://svn.onehippo.org/repos/hippo/hippo-ecm/trunk/repository/engine/src/main/java/org/hippoecm/repository/query/lucene/ServicingNodeIndexer.java
>
> Bernd
>
>>
>> regards
>> marcel
>>
>>> The downside of not being able to do this (controlling Lucene doc
>>> creation) is having another, self-managed index, and (re-)indexing must
>>> be done by hand, using JCR listeners or some other approach.
>>>
>>> Bernd
>>>
>>
>
>
Re: Controlling the Lucene indexing
Posted by Ard Schrijvers <a....@onehippo.com>.
Hello,
> Feature-downgrading doesn't help me. I have a clear need how nodes must
> be indexed. Since there seems to be no easy way to do this in
> Jackrabbit, so I fall back to my own index.
> And that's ok for me. I just asked (although I looked at the code) to
> not miss something.
>
> Thanks for all your patience and help!
Sry for dropping in so late, I have been to occupied lately to even
follow the list. Hope to have more time in near future. Anyways, my 2
cents about this:
First of all, I think we already exactly did exactly what Bernd wants
(without hooking in your own index and keep it in sync: i wouldn't go
there). Also, I would favor support for more indexing tuning within
Jackrabbit. I think everybody accustomed to lucene, or Solr, is used
to define *how* fields should be indexed. Now, we have quite some
support for this in JackRabbit already, see [1], but some tuning is
missing (for example I would like to be able to indicate that lucene
should not index some property (summary) as a single term, as I never
want to sort on it, or use equals for it....)
As you can find at the buttom of [1], you can configure a *per*
property analyzer. So, if I know I have some comma seperate keywords
property, I could configure the property to be indexed with my
CommaSeperatedKeyWordAnalyzer. So basically, support for it is there.
Now, what is not currently easy to achieve is for example indexing one
and the same property in multiple ways: If for example I am indexing a
title property, I might also want to index a short_title (which is not
a jcr property, just index field only) : now, if I have 1.000.000 text
documents having a title, I could still do a sort on short_title,
whereas sorting on the normal title field will result in instant OOM
(I am actually facing this, and will use some kind of 'short_title'
strategy...where similar stuff applies for date range queries wrt
different granularities)
Anyways, back to Bernd's thing:
We provided faceted navigation exposed over jcr as virtual structures.
Similar I am planning to do so for Taxonomy navigation, tagging
navigation, lucene term space navigation (exposing auto-completion
options), similar nodes navigation, broken link checker, etc etc. But,
some of them, for example faceted navigation needed, I think, the very
same thing Bernd wants: controlling how properties are being indexed.
As Marcel points out, you only need to extend the SearchIndex and
override createDocument. You can then also use your own NodeIndexer
impl which indexes all the properties (and index a single property in
multiple ways) the way you want. The only drawback that makes it a
little more difficult to write, is that for historical reasons (as it
was not possible with the lucene version used at the time of writing
the jr indexing) all properties end up in a single lucene property
field, hence, you need to do some field value prefixing tricks (not
hard, just a little annoying and confusing from time to time :-))
In your repository.xml, in the <SearchIndex> element, change for example:
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> to
<SearchIndex class=",,,..query.lucene.MySearchIndex">
Anyways, you can take look at [2] and [3] for examples, though they
are already somewhat more sophisticated as we added custom indexing
configurations as well for optimizing indexing (for example date
granularity config which I actually still need to add)
Hope this helps
Regards Ard
[1] http://wiki.apache.org/jackrabbit/IndexingConfiguration
[2] http://svn.onehippo.org/repos/hippo/hippo-ecm/trunk/repository/engine/src/main/java/org/hippoecm/repository/query/lucene/ServicingSearchIndex.java
[3] http://svn.onehippo.org/repos/hippo/hippo-ecm/trunk/repository/engine/src/main/java/org/hippoecm/repository/query/lucene/ServicingNodeIndexer.java
>
> Bernd
>
>>
>> regards
>> marcel
>>
>>> The downside of not being able to do this (controlling Lucene doc
>>> creation) is having another, self-managed index, and (re-)indexing must
>>> be done by hand, using JCR listeners or some other approach.
>>>
>>> Bernd
>>>
>>
>
>
Re: Controlling the Lucene indexing
Posted by Bernd Fondermann <bf...@brainlounge.de>.
Marcel Reutegger wrote:
> Hi,
>
> 2009/6/8 Bernd Fondermann <bf...@brainlounge.de>:
>> It'd open a nice set of applications.
>> For example, if I tag docs, type them or keep headlines or authors in
>> separate attributes (and fields), I could do much more sophisticated
>> searches.
>
> I see.
>
> Did you consider storing this additional information as regular
> content?
No, because I want to control the indexing and storing behavior per field.
> i.e. create a regular JCR property instead of creating this
> low-level-behind-the-scences fields in lucene. then run the more
> sophisticated searches on those additional properties.
How could that work? I could not differentiate using Lucene query field
qualifiers.
Feature-downgrading doesn't help me. I have a clear need how nodes must
be indexed. Since there seems to be no easy way to do this in
Jackrabbit, so I fall back to my own index.
And that's ok for me. I just asked (although I looked at the code) to
not miss something.
Thanks for all your patience and help!
Bernd
>
> regards
> marcel
>
>> The downside of not being able to do this (controlling Lucene doc
>> creation) is having another, self-managed index, and (re-)indexing must
>> be done by hand, using JCR listeners or some other approach.
>>
>> Bernd
>>
>
Re: Controlling the Lucene indexing
Posted by Marcel Reutegger <ma...@gmx.net>.
Hi,
2009/6/8 Bernd Fondermann <bf...@brainlounge.de>:
> It'd open a nice set of applications.
> For example, if I tag docs, type them or keep headlines or authors in
> separate attributes (and fields), I could do much more sophisticated
> searches.
I see.
Did you consider storing this additional information as regular
content? i.e. create a regular JCR property instead of creating this
low-level-behind-the-scences fields in lucene. then run the more
sophisticated searches on those additional properties.
regards
marcel
> The downside of not being able to do this (controlling Lucene doc
> creation) is having another, self-managed index, and (re-)indexing must
> be done by hand, using JCR listeners or some other approach.
>
> Bernd
>
Re: Controlling the Lucene indexing
Posted by Bernd Fondermann <bf...@brainlounge.de>.
Marcel Reutegger wrote:
> Hi,
>
> On Mon, Jun 8, 2009 at 14:49, Bernd Fondermann <bf...@brainlounge.de> wrote:
>> I want to control how JCR attributes are mapped to Lucene Document fields.
>
> that's not easily possible. what is the reason you want to do this?
>
> if you still want to do that, then you could write your own
> QueryHandler implementation by extending from SearchIndex. Then
> overwrite the method createDocument().
It'd open a nice set of applications.
For example, if I tag docs, type them or keep headlines or authors in
separate attributes (and fields), I could do much more sophisticated
searches.
The downside of not being able to do this (controlling Lucene doc
creation) is having another, self-managed index, and (re-)indexing must
be done by hand, using JCR listeners or some other approach.
Bernd
Re: Controlling the Lucene indexing
Posted by Marcel Reutegger <ma...@gmx.net>.
Hi,
On Mon, Jun 8, 2009 at 14:49, Bernd Fondermann <bf...@brainlounge.de> wrote:
> I want to control how JCR attributes are mapped to Lucene Document fields.
that's not easily possible. what is the reason you want to do this?
if you still want to do that, then you could write your own
QueryHandler implementation by extending from SearchIndex. Then
overwrite the method createDocument().
regards
marcel
Re: Controlling the Lucene indexing
Posted by Bernd Fondermann <bf...@brainlounge.de>.
Marcel Reutegger wrote:
> Hi,
>
> On Wed, May 20, 2009 at 21:54, Bernd Fondermann <bf...@brainlounge.de> wrote:
>> Alexander Klimetschek wrote:
>>> On Wed, May 20, 2009 at 5:29 AM, Bernd Fondermann <bf...@brainlounge.de> wrote:
>>>> Is it possible to control for the built-in Lucene indexing how
>>>> Jackrabbit Nodes are indexed with respect to how Attributes are mapped
>>>> to Lucene Fields and when Storing, Indexing and Tokenizing is applied?
>>> Have a look at
>>>
>>> http://wiki.apache.org/jackrabbit/Search
>>>
>>> There are some things to configure, for example you can provide a
>>> different Lucene analyzer ("analyzer" parameter).
>> Yes, I was already aware of that page. I browsed the Jackrabbit code,
>> too. But I don't see that controlling per-Attribute indexing is
>> possible, is it?
>
> I'm not sure what exactly you want to control, but the indexing
> configuration [0] allows you to tweak some of the indexing behaviour.
I want to control how JCR attributes are mapped to Lucene Document fields.
Bernd