cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene Query

pascal
Champ in-the-making
Champ in-the-making
Hi,

I'm currently working at a C# Project using web services.
I created 2 custom attributes:

- language (text)
- type  (text)

I'd like to search all the documents that are from a specified document type.

This code snippet returns me all the documents that are from type "KT-HT":

// Create a query object, looking for all items with alfresco in the name of text

RepositoryService.Query query = new RepositoryService.Query();
query.language = RepositoryService.QueryLanguageEnum.lucene;

query.statement = "@my\\:type:'KT-HT'";

// Execute the query
QueryResult queryResult = this.repoService.query(this.spacesStore, query, false);
       
But if I want tu use wildcards in the query statement like this:

query.statement = "@my\\:type:'KT*'";

I get an empty resultset.

Any clue of what I am doing wrong would be greatly appreciated.

Thanks a lot.

Pascal
4 REPLIES 4

andy
Champ on-the-rise
Champ on-the-rise
Hi


query.statement = "@my\\:type:KT*";

Should work.

If the text is in double quotes it is treated as a phrase (no wild cards allowed). See http://lucene.apache.org/java/docs/queryparsersyntax.html

I am a bit confused here as phrases should be surrounded by double quotes and you have single quotes.

Your text will be tokenised when indexed. Depending on the attribute type and config this probably goes in as two tokens KT and HT. KT* should work.


You may also consider:
* grouping things using categories
* having real types and using the TYPE:"….." lucene attribute (which will expand to include all subtypes of the specified type)


Regards

Andy

pascal
Champ in-the-making
Champ in-the-making
Hi Andy,

Thank you very much for your quick answer.

I tried with

query.statement = "@my\\:type:KT*"; 

But I still get an empty resultset.

Here is the defintion of my custom attribute:

<types>
       <type name="my:customeType">
         <title>Type</title>
         <parent>cm:content</parent>
         <properties>
            <property name="my:type>
                <type>d:text</type>
            </property>
         </properties>
</type>


Did I miss something in the definition or in the config files ?

Thank you for your help.

Pascal

andy
Champ on-the-rise
Champ on-the-rise
Hi

The model looks OK.

I forgot that the text tokeniser will be converting everything to lower case.
So you will need  

query.statement = "@my\\:type:kt*";

This form of query (wild card) does not go through the tokeniser so will be used "as is".

If you want an exact match you will need

query.statement = "+@my\\:type:kt  +@my\\:type:ht";

or

query.statement = "+@my\\:type:\"KT-HT\"";


Apologies

Regards

Andy

pascal
Champ in-the-making
Champ in-the-making
Hi Andy,

I finally managed to get a correct resultset by using:

query.statement = "+@\\{my.new.model\\}type:kt*) ";

It was the only way for me to use wildcards in the query.

Thank your for your help.
I am very satisfied with your amazing product.

Regards.

Pascal
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.