cancel
Showing results for 
Search instead for 
Did you mean: 

help with a lucene query

dcrossma
Champ in-the-making
Champ in-the-making
I have the following code

public void testSearchAPI() {


        try {
            AuthenticationUtils.startSession(USERNAME, PASSWORD);
        } catch (AuthenticationFault authenticationFault) {
            authenticationFault.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }


        Query query = new Query(Constants.QUERY_LANG_LUCENE, "TEXT:Da*");

        RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();


        try {
            QueryResult queryResult = repositoryService.query(STORE, query, true);

            Assert.assertNotNull("queryResult should not be null", queryResult);
            String querySession = queryResult.getQuerySession();
            Assert.assertNotNull("querySession should not be null", querySession);

            ResultSet resultSet = queryResult.getResultSet();
            Assert.assertNotNull("The result set should not be null", resultSet);


            System.out.println("number of results" + resultSet.getRows().length);
            ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
            int i=0;
            for (ResultSetRow row : resultSet.getRows()) {

                Reference ref = new Reference();
                ref.setUuid(row.getNode().getId());
                ref.setStore(STORE);

                // Read the newly added content from the respository
                Content[] readResult = new Content[0];
                try {
                    readResult = contentService.read(new Predicate(new Reference[]{ref}, STORE, null), Constants.PROP_CONTENT);
                } catch (RemoteException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }
                Content content = readResult[0];


                System.out.println("content url " + content.getUrl());
                ContentFormat format =content.getFormat();

                System.out.println("format is"+format.getMimetype());

               
                if(format.getMimetype().equals("application/pdf")){
                ContentUtils.copyContentToFile(content, new File("/home/dcrossma/Desktop/doc"+ ++i +".pdf"));

                    row.getNode().

                }
               
            }


        } catch (RemoteException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } finally {
            // End the session
            AuthenticationUtils.endSession();

        }


    }

In my repository i have created some custom metadata fields eg csgSmiley Tongueroponent  I would like to search for all spaces that have this field with a value say Dave.

Is this possible ???? I have never queried with lucene before so i am struggling a little 🙂
2 REPLIES 2

dcrossma
Champ in-the-making
Champ in-the-making
The following query game me what I wanted

Query query = new Query(Constants.QUERY_LANG_LUCENE, "+@\\{csg.model\\}proponent:\"test\" AND (TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\")");

putodemonio
Champ in-the-making
Champ in-the-making
Hi!
The code

String strQuery= "+@{cice.salaprensa.model}fuente:Load";
Query query = new Query(Constants.QUERY_LANG_LUCENE, strQuery);
QueryResult rootChildren = repositoryService.query(STORE, query, true);

thows me this:



AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
   {http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>Failed to parse query: +@{cice.salaprensa.model}fuente:Load</ns1:message>
   {http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.repository.RepositoryFault
   {http://xml.apache.org/axis/}stackTrace:
   at org.alfresco.repo.webservice.repository.RepositoryWebService.query(RepositoryWebService.java:233)
   at sun.reflect.GeneratedMethodAccessor612.invoke(Unknown Source)


I repeat: Failed to parse query: +@{cice.salaprensa.model}fuente:Load

What I'm doing wrong???!!!
Smiley Sad  Smiley Sad