cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene works when it want

chicco0386
Champ on-the-rise
Champ on-the-rise
Hi all, I've this function that retrive execute a lucene query and return a list of reference:
    public static List<Reference> searchLuceneFromTheRoot(String toSearch) {

        List<Reference> toReturn = new ArrayList<Reference>();
        RepositoryServiceSoapBindingStub repoService = WebServiceFactory.getRepositoryService();
        String encodedString = ISO9075.encode(toSearch);
        String queryPath = "PATH:\"/app:company_home//*\" ";
        String queryTitlet = "+@cm\\:name:\"" + encodedString + "\"";
        String statement = queryPath.concat(queryTitlet);
        if (log.isDebugEnabled()) {
            log.debug("searchLuceneFromTheRoot, statement [" + statement + "]");
        }
        Query query = new Query(Constants.QUERY_LANG_LUCENE, statement);
        QueryResult results = null;
        ResultSet resultSet = null;
        NamedValue currentNamedValue;
        String path;
        String id;
        try {
            results = repoService.query(getStore(), query, false);
            resultSet = results.getResultSet();
            if (resultSet.getTotalRowCount() == 0) {
                log.info("searchLuceneFromTheRoot, NON ho trovato nessun file con titolo [" + toSearch + "]");
            } else {
                log.info("searchLuceneFromTheRoot, ho trovato [" + resultSet.getTotalRowCount() + "] file con nome [" + toSearch + "]");
                for (int i = 0; i < resultSet.getTotalRowCount(); i++) {
                    NamedValue[] namedValues = resultSet.getRows()[i].getColumns();
                    path = null;
                    id = null;
                    for (int y = 0; y < namedValues.length; y++) {
                        currentNamedValue = namedValues[y];
                        if (currentNamedValue.getName().equals(ContentModel.PROP_NODE_UUID.toString())) {
                            id = currentNamedValue.getValue();
                            if (log.isDebugEnabled()) {
                                log.debug("searchLuceneFromTheRoot, ID: " + id);
                            }
                        }
                        if (currentNamedValue.getName().equals("{http://www.alfresco.org/model/content/1.0}path")) {
                            path = rewritePathFromProp(currentNamedValue.getValue());
                            if (log.isDebugEnabled()) {
                                log.debug("searchLuceneFromTheRoot, PATH: " + path);
                            }
                        }
                        if (id != null && path != null) {
                            Reference toInsert = new Reference(getStore(), id, path);
                            toReturn.add(toInsert);
                        }
                    }
                }
            }
        } catch (ContentFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RepositoryFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return toReturn;
    }

Sometime this code works fine and sometime doesn't work because the query don't find anything although the file to search is inside Alfresco.

PLEASE CAN YOU HELP ME?

THANKS YOU
7 REPLIES 7

chicco0386
Champ on-the-rise
Champ on-the-rise
ANYONE CAN HELP ME?

TANK YOU

chicco0386
Champ on-the-rise
Champ on-the-rise
This problem for me is very important, can someone help me or give me a workaround?

Thank you

mrogers
Star Contributor
Star Contributor
Start by
a) making it easy for people to be able to see the query rather than having to reverse engineer your code.
b) don't "bump" your own topics since it makes it look like someone has answered your questions.
c) don't shout with all caps.

chicco0386
Champ on-the-rise
Champ on-the-rise
This is the code simplified:
public static boolean userExist(String userName, String nome, String cognome) throws RepositoryFault, RemoteException {
      RepositoryServiceSoapBindingStub repoService = WebServiceFactory.getRepositoryService();
      String queryTitlet = "+@cm\\:firstName:\"" + nome + "\" +@cm\\:lastName:\"" + cognome + "\"";
      Query query = new Query(Constants.QUERY_LANG_LUCENE, queryTitlet);
      QueryResult results = null;
      ResultSet resultSet = null;
      results = repoService.query(new Store(Constants.WORKSPACE_STORE, "SpacesStore"), query, false);
      resultSet = results.getResultSet();
}

This piece of code works sometime and other time it say me that there is not results.

gyro_gearless
Champ in-the-making
Champ in-the-making
Hi,

i sometimes found Alfresco's out-of-the-box settings for pruning lucene query a source of nasty bugs, so maybe try this (as an elaborated guess) in your alfresco-global.properties


# The maximum time spent pruning results
# system.acl.maxPermissionCheckTimeMillis=10000
system.acl.maxPermissionCheckTimeMillis=600000

chicco0386
Champ on-the-rise
Champ on-the-rise
Hi,

i sometimes found Alfresco's out-of-the-box settings for pruning lucene query a source of nasty bugs, so maybe try this (as an elaborated guess) in your alfresco-global.properties


# The maximum time spent pruning results
# system.acl.maxPermissionCheckTimeMillis=10000
system.acl.maxPermissionCheckTimeMillis=600000

Thank you for the reply, but the problem appears again.

Others solutions?
Please I need your help

himvj
Champ in-the-making
Champ in-the-making
where i can find the class
RepositoryServiceSoapBindingStub
I am new to alfresco I am using Visual studio 2005
please tel…..