Alfresco Lucene search with numeric folder name

cancel
Showing results for 
Search instead for 
Did you mean: 
brijeshnk
Established Member

Alfresco Lucene search with numeric folder name

Jump to solution

Hi there , 

I have a folder with name '2020' in alfresco document library ,  I need to navigate to this folder to fetch documents and contents . 

I was using following query using Alfresco Java API 

 

String query1 = "PATH:\"/app:company_home/st:sites/cm:operational-document/cm:documentLibrary/cm:Business-Documents/cm:CLAIM/cm:2020//*\" AND (TYPE:\"cm:content\" OR TYPE:\"cm:folder\")";
LOG.info("query1 :: "+query1);
ResultSet rs = serviceRegistry.getSearchService().query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_LUCENE,query1);

 

The above query results following exception  , When i removed folder name 2020  , all works fine .    following query works fine 

String query1 = "PATH:\"/app:company_home/st:sites/cm:operational-document/cm:documentLibrary/cm:Business-Documents/cm:CLAIM//*\" AND (TYPE:\"cm:content\" OR TYPE:\"cm:folder\")";
LOG.info("query1 :: "+query1);
ResultSet rs = serviceRegistry.getSearchService().query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_LUCENE,query1);

                            Am i making any mistake  in query. How to pass folder name with only numeric while using lucene search  ? 

Lucense parser exception - 

2020-02-21 12:22:00,192 INFO [com.uia.archive.movedata.MoveMonthlyData] query1 :: PATH:"/app:company_home/st:sites/cmSmiley Surprisedperational-document/cm:documentLibrary/cm:Business-Documents/cm:CLAIM/cm:2020//*" AND (TYPE:"cm:content" OR TYPE:"cm:folder")
2020-02-21 12:22:22,997 ERROR [org.quartz.core.JobRunShell] Job DEFAULT.moveMonthlyDataActionBean threw an unhandled Exception:
org.alfresco.repo.search.impl.lucene.LuceneQueryParserException: 01210024 Request failed 400

/solr4/alfresco/alfresco?wt=json&fl=DBID%2Cscore&rows=1000&df=TEXT&start=0&locale=en_GB&alternativeDic=DEFAULT_DICTIONARY&fq=%7B%21afts%7DAUTHORITY_FILTER_FROM_JSON&fq=%7B%21afts%7DTENANT_FILTER_FROM_JSON
at org.alfresco.repo.search.impl.solr.SolrQueryHTTPClient.postQuery(SolrQueryHTTPClient.java:1159)
at org.alfresco.repo.search.impl.solr.SolrQueryHTTPClient.postSolrQuery(SolrQueryHTTPClient.java:1109)
at org.alfresco.repo.search.impl.solr.SolrQueryHTTPClient.executeQuery(SolrQueryHTTPClient.java:576)
at org.alfresco.repo.search.impl.solr.SolrQueryLanguage.executeQuery(SolrQueryLanguage.java:58)
at org.alfresco.repo.search.impl.solr.SolrSearchService.query(SolrSearchService.java:355)
at org.alfresco.repo.search.impl.solr.SolrSearchService.query(SolrSearchService.java:159)
at org.alfresco.repo.search.SearcherComponent.query(SearcherComponent.java:73)
at org.alfresco.repo.search.AbstractSearcherComponent.query(AbstractSearcherComponent.java:60)
at sun.reflect.GeneratedMethodAccessor528.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyF

Any suggerstions ? 

Thanks a lot 

1 Solution

Accepted Solutions
angelborroy
Alfresco Employee

Re: Alfresco Lucene search with numeric folder name

Jump to solution

You need to escape the first character of the name if it's a number:

String query1 = "PATH:\"/app:company_home/st:sites/cm:operational-document/cm:documentLibrary/cm:Business-Documents/cm:CLAIM/cm:_x0032_020//*\" AND (TYPE:\"cm:content\" OR TYPE:\"cm:folder\")";
Hyland Developer Evangelist

View solution in original post

2 Replies
angelborroy
Alfresco Employee

Re: Alfresco Lucene search with numeric folder name

Jump to solution

You need to escape the first character of the name if it's a number:

String query1 = "PATH:\"/app:company_home/st:sites/cm:operational-document/cm:documentLibrary/cm:Business-Documents/cm:CLAIM/cm:_x0032_020//*\" AND (TYPE:\"cm:content\" OR TYPE:\"cm:folder\")";
Hyland Developer Evangelist
brijeshnk
Established Member

Re: Alfresco Lucene search with numeric folder name

Jump to solution