1 Reply Latest reply on Jun 28, 2013 7:04 PM by Sham HC

    CQ5 get partly right results from Query

    Jakolcz

      I'm trying to search in nodes via QueryBuilder/Query but it doesn't seem to work fine. I have following code method to search in about 6000 records.

         

      public String searchRows(String search, int start, int length){
                  Map<String, String> searchMap = new HashMap<String, String>();
                  searchMap.put("path", this.path);
                  searchMap.put("fulltext", search);
                  Query query = this.builder.createQuery(PredicateGroup.create(searchMap), this.session);
                  query.setStart(start);
                  query.setHitsPerPage(length);
                  SearchResult result = query.getResult();
                  //return result.getQueryStatement();
                  StringBuilder sb = this.createBasicInfo(result.getTotalMatches());
                  sb.append(this.toaaData(result));
                  sb.append("}");
                  return sb.toString();
              }
      

      and I want to get results that just partly matches. For example I have node with these properties

         

      Company   "My Drugstore Abc"
          City      "My City"
          Street    "Some Street"
      

      If i try to search for "Abc" I get the right result but if I try to search for "drugstore" or "my" i get nothing. Also if I try to search "city" or "street" I get nothing... How can I solve this? I've tried to edit the search term like this

         

      searchMap.put("fulltext", "*"+search+"*");
      

      but it's too slow, about 1-6 seconds per query.

      This is the Xpath i get from result.getQueryStatement();

         

      /jcr:root/my/path//*[jcr:contains(., 'city')]
      

      Thanks for any help