cancel
Showing results for 
Search instead for 
Did you mean: 

ResultSetRow.getValues is null for certain queries?

hagak
Champ in-the-making
Champ in-the-making
Below is a sinppet of code


      StringBuffer sbQuery = new StringBuffer();
      sbQuery.append("TYPE:\"cm:person\"");

      if (!StringUtils.isBlank(filter)) {
         sbQuery.append(" AND ALL:\"" + filter + "*\"");
      }
      SearchService searchService = serviceRegistry.getSearchService();
      
      SearchParameters sp = new SearchParameters();
      sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
      sp.setLanguage(SearchService.LANGUAGE_LUCENE);
      sp.addTextAttribute("@" + ContentModel.PROP_LASTNAME.toString());
      sp.setQuery(sbQuery.toString());
      sp.setMaxItems(100);
      sp.addSort("@" + ContentModel.PROP_LASTNAME.toString(), true);
      sp.addSort("@" + ContentModel.PROP_FIRSTNAME.toString(), true);
      sp.addSort("@" + ContentModel.PROP_USERNAME.toString(), true);
      ResultSet resultsset = null;
      try {
         resultsset = searchService.query(sp);
         // ResultSet resultsset = searchService.query(SSICConstants.STORE,
         // SearchService.LANGUAGE_LUCENE, sbQuery.toString());

         Iterator<ResultSetRow> itr = resultsset.iterator();
         while (itr.hasNext()) {
            ResultSetRow currentRow = itr.next();
            currentRow.getNodeRef() // RETURNS as Expected every time
                                currentRow.getValues() //RETURNS NULL if the above var filter is not null, returns as expect if filter is null
         }
      } finally {
         if (resultsset != null) {
            resultsset.close();
         }
      }


Issue is if the "filter" is empty so that is does not append the "AND ALL:" to the query the getValues returns all of the properties of the node.  However if the filter is set and it still returns the expected nodes, the getValues for those nodes is null.

Other note is if I do the same query without using SearchParameters and just doing it from the query(x,x,x) method the getValues returns as expected.

P.S.  I know I should use parameterized query, still trying to figure out how to set the QName on that.  If anyone has examples of using that would be helpful.
1 REPLY 1

hagak
Champ in-the-making
Champ in-the-making
After messing with various knobs, I looked at the useInMemorySort option.  So if it uses the inmemorysort because the result set is below the threshold then I get no properties in the ResultSet just the noderef.  If the resultset is too large it then does the sort differently and it includes the properties.  So if I set setUseInMemorySort(false) it works everytime

This seems like a bug that the resultset changes based on how it decides to do the sort, also kind of defeats the advantage of doing the sort faster inmemory if you then have to go back and fetch the property values of the nodes.