cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene query with extact phase?

spilby
Confirmed Champ
Confirmed Champ
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!

12 REPLIES 12

Oh,ok. I think that I see the problem… In our desalModel.xml, all the properties that we added have the
<index enabled="true">
. SOLR use this desalModel, because of this, we can find those properties. I understand that we should only put enabled true on the properties that we want to find when use the searchService.query().

I use Alfresco share 4.2 with SOLR, and use fts-alfresco language on the query because I use the "=" to find exact results.

I want to be sure that when me call to searchService.query() with LANGUAGE_FTS_ALFRESCO I use the index and not the database, for a better performance and speed. In conclusion… If I put index enabled=true on the A property, and I use searchService.query() with LANGUAGE_FTS_ALFRESCO to find this A property, I will be use the index to search the property and not the database?

And if you know, for curiosity… What is LANGUAGE_SOLR_FTS_ALFRESCO? I must use it if I have SOLR?



kaynezhang
World-Class Innovator
World-Class Innovator
1.In model definition , property is indexed by default ,so if you have not set enabled="false" explicitly ,it will be indexed.
2. Property definition has nothing do to with whether to search in index or search in db ,it is controlled by "solr.query.cmis.queryConsistency" parameter in alfresco-global.properties(if not exist,you can add it).If you set "solr.query.cmis.queryConsistency" to "EVENTUAL" ,it will search index first,but you run the risk of finding nothing.
3.Language SOLR_FTS_ALFRESCO has the same effect as language FTS_ALFRESCO in solr subystem.

Oks! Perfect. Thank you very much! Smiley Happy