AnsweredAssumed Answered

Finding Content that has custom aspects

Question asked by unknown-user on Jun 7, 2010
Latest reply on Jun 7, 2010 by unknown-user
I am writing a web script to retrieve content by a custom set of aspects that I have added.  I am finding that the query is not returning what I am expecting.  Below is the code that I have used.  I will admit, I am shaky on the paramDefs being necessary or correct.  Input would be appreciated.

DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(
            null);
      namespacePrefixResolver.registerNamespace("custom", "custom.model");

      QueryParameterDefinition[] paramDefs = new QueryParameterDefinition[3];
      QueryParameterDefImpl productParamDef = new QueryParameterDefImpl(QName
            .createQName("custom:productIdenifier", services.getNamespaceService()),
            (DataTypeDefinition) null, true, getProductId());
      QueryParameterDefImpl sampleParamDef = new QueryParameterDefImpl(QName
            .createQName("custom:sample", services.getNamespaceService()),
            (DataTypeDefinition) null, true, Boolean.toString(getSample()));
      QueryParameterDefImpl typeParamDef = new QueryParameterDefImpl(QName
            .createQName("custom:primary", services.getNamespaceService()),
            (DataTypeDefinition) null, true, Boolean.toString(getPrimary()));
      paramDefs[0] = productParamDef;
      paramDefs[1] = sampleParamDef;
      paramDefs[2] = typeParamDef;
      
      ResultSet results = null;
      NodeRef nodeRef = null;
      try {
         
         results = services.getSearchService().query(
               rootNodeRef.getStoreRef(), "lucene",
               "@custom\\:productIdentifier:'" + getProductId() +
               "' AND @custom\\:sample:'" + getSample() +
               "' AND @custom\\:primary:'" + getPrimary() + "'",
               paramDefs);
         if(results.length() > 0) {
            nodeRef = results.getNodeRef(0);
         }
      } finally {
         if (results != null) {
            results.close();
         }
      }
      return nodeRef;



Thank you in advance.

Outcomes