AnsweredAssumed Answered

help with a lucene query

Question asked by dcrossma on Mar 1, 2007
Latest reply on Jun 8, 2007 by putodemonio
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 csg:proponent  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 :-)

Outcomes