Home

Lucene query with extact phase?

You are here

10 posts / 0 new
Last post
Lucene query with extact phase?

I want to find with Lucene a node with a property. Exactly with this text. I'm using Alfresco 4.2 and the Alfresco Java API.

For example, imagine I have in Alfresco 2 nodes with my velocity_number property. One with the value "A B" and the other with the value "A B C".

On my webscript, I do this:

SearchParameters sp = new SearchParameters();
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(query);
ResultSet results = getSearchService().query(myQuery);

where myQuery is:

PATH: "//app:company_home/app:user_homes/cm:dir//." AND @own\:velocity_number:"A B"

This query returns me the 2 nodes, "A B" and "A B C". I don't want this, I only want "A B" node.

I thank that the solution was add an "=" character on the query, like this:

PATH: "//app:company_home/app:user_homes/cm:dir//." AND =@own\:velocity_number:"A B"

But don't find anything, the results is 0.

How is the query to find that I want?

If I do the same with the Node Browser of the Administration Console (with Lucene search) the same... 0 results. The character "=" only works for me if and find 1 result if I put the query on the Search combo on the Alfresco Explorer (advanced search).

Thanks!

indexing behaviour

How did you configure indexing behaviour in your model definition?
You should set  Tokenised="both" or  Tokenised="false" in your property index config, then "=" character query will work.like below

           <property name="own:velocity_number">
<type>d:content</type>
<mandatory>false</mandatory>
<index enabled="true">
<atomic>false</atomic>
<stored>false</stored>
<tokenised>both</tokenised>
</index>
</property>

The difference among "true","both","false" is :
If "true", the string value of the property is tokenized before indexing
if "false", it is indexed "as is" as a single string
if "both" then both forms above are in the index

So set it to "both" will be a good option.

If this post was helpful, please click Yes on the Post Rating

Yes, I have tokenised false.

Yes, I have tokenised false. This is my xml, similar than your propose:

<property name="own:velocity_number">
<type>d:text</type>
<mandatory>true</mandatory>
<index enabled="true">
<atomic>false</atomic>
<stored>true</stored>
<tokenised>false</tokenised>
</index>
</property>

But the = character not works. Don't find anything. :o(

For more info... If I do the same with the Node Browser of the Administration Console (with Lucene search) the same... 0 results. The character "=" only works for me if and find 1 result if I put the query on the Search combo on the Alfresco Explorer (advanced search).

fts-alfresco

Use character "=" you should use "fts-alfresco" language instead of lucene

If this post was helpful, please click Yes on the Post Rating

I thank use the webscript

I thank use the webscript using Lucene. Some properties are indexing. But I can use sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO)? What may be the consequence if I use FTS-ALFRESCO instead of Lucene? Is the same? The same performance efficiency?

And using Lucene, what's the equivalence with the "="?

fts-alfresco

You still can use fts-alfresco language in javascript api ,just call it like this

 var def =
{
query: "=@own\:velocity_number:\"A B\"",
language: "fts-alfresco"
};
var results = search.query(def);

As performance efficiency and consequence,I don't think it is a problem.In my opionion it is almost the same as lucene language.

If this post was helpful, please click Yes on the Post Rating

Thanks, with fts-alfresco

Thanks, with fts-alfresco works ok! It find my own property.

I only have a problem now with the query when I search by the alfresco uuid. I use this in the query:

   @sys\\:node-uuid:"6647a596-53e9-4676-adc4-a77d79487fdf";

When I use Lucene, it works ok, but when I change to fts-alfresco, don't works. What's the equivalence in fts to search a node by uuid?

Note: I use a java backed webscript, not javascript.

Thanks again!

ID

You can try to use ID as instead

 ID:workspace\://SpacesStore/ce55a850-b1c7-43c7-a600-b5c58a985429

If this post was helpful, please click Yes on the Post Rating

Only one question more about

Only one question more about indexing...

On my webscript, now I do this:

SearchParameters sp = new SearchParameters();
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.setQuery(query);
ResultSet results = getSearchService().query(myQuery);

where myQuery is:

PATH: "//app:company_home/app:user_homes/cm:dir//." AND =@own\:velocity_number:"A B"

We use SOLR. And the "own" property that I search is not indexed. But the query find me the result.

How is possible? We can find results that aren't indexed on SOLR? This indexation only affects the speed/performance of the query? Or maybe it depends if I use FTS-ALFRESCO or LUCENE?

Thanks again!

fts-alfresco

fts-alfresco query language is special.It can search in database or in index depends on configuration. By default it will search in db first,so you can find what is not indexed.

If this post was helpful, please click Yes on the Post Rating