Thanks for your response, Davide, I did get the propertyIndex to work!

I have one question however:
I can only get the query to work when querying for nt:unstructured, but
not for nt:base. Is this the expected behaviour?

I can create my index either with the „declaringNodeTypes“ property set to
„nt:base“ or with the property omitted:

Node propertyIndexNode =
session.getNode("/oak:index").addNode("testIndex",
"oak:QueryIndexDefinition");
            propertyIndexNode.setProperty("type", "property") ;
            propertyIndexNode.setProperty("propertyNames",
"trainingProperty");
            propertyIndexNode.setProperty("declaringNodeTypes","nt:base“);
// can be omitted
            propertyIndexNode.setProperty("unique", false);
            propertyIndexNode.setProperty("reindex", true);

In both cases the following query is using the index:
SELECT *  FROM [nt:unstructured] WHERE trainingProperty = 13

But the following query is not:
SELECT *  FROM [nt:base] WHERE trainingProperty = 13


Thanks,
Ben

Inside Solutions AG | Felsenstrasse 11 | 4450 Sissach | Schweiz
Telefon: +41 61 551 00 40 | Direkt: +41 61 551 00 43
http://www.inside-solutions.ch <http://www.inside-solutions.ch/>





Am 14.03.14 09:12 schrieb "Davide Giannella" unter
<giannella.dav...@gmail.com>:

>On 13/03/2014 17:41, Ben Zahler wrote:
>> I execute the following query:
>> String expression = "SELECT *  FROM [nt:base] WHERE trainingProperty >
>> 10";
>> Query query = queryManager.createQuery(expression,Query.JCR_SQL2);
>>
>> As expected, I get the message
>>  WARN  o.a.j.o.s.q.Cursors$TraversingCursor - Traversed 1000 nodes
>> with filter Filter(query=SELECT *  FROM [nt:base] WHERE
>> trainingProperty > 10, path=/*, property=[trainingProperty=(10..]);
>> consider creating an index or changing the query
>>
>> ...
>>             Node propertyIndexNode =
>> session.getNode("/oak:index").addNode("testIndex",
>> "oak:QueryIndexDefinition");
>>             propertyIndexNode.setProperty("type", "property") ;
>>             propertyIndexNode.setProperty("propertyNames",
>> "trainingProperty");
>>             propertyIndexNode.setProperty("unique", false);
>>             propertyIndexNode.setProperty("reindex", true);
>>             session.save();
>>
>The PropertyIndex does not react on range queries. Only equality, in and
>nonnull properties.
>
>D.
>
>

Reply via email to