5 Replies Latest reply: Apr 14, 2012 3:04 AM by sameerdh RSS

    constructing ENEQuery

    sameerdh
      Hi all,

      I'm facing problems while creating ENEQuery.....Constructed Query results is showing all items even if i select the dimension.

      I Created query by creating an instance of ENEQuery and added params like N NE and Ntt Ntk Ntx

      But if i use the same params in ref app im getting all results...

      Ref app constructs like &Ntx=mode+matchall &Ntk=All &Ne=10002 &N=4294967233 &Ntt=pant


      Is there any way we can construct the order of params similar to reference app ?

      I'm using JAVA.Your help will be appreciated.

      Sameer
        • 1. Re: constructing ENEQuery
          TimK
          Hi Sameer - do you have a code snippet for adding the dimension value to your query object? It's a bit tricky in Java to set these...
          -Tim
          • 2. Re: constructing ENEQuery
            sameerdh
            Thanks tim for your reply.... and sorry for late response...

            See my attached ... code snippet..... we are constructing params based on ref app... not sure this is the standard way...

            public UrlENEQuery generateKeywordQuery(HttpServletRequest pRequest,
                           UrlFormatter urlFormatter, QueryBuilder pQueryBuilder,String pQuestion)
                           throws UrlFormatException, QueryBuildException,
                           UrlENEQueryParseException {
                      UrlState urlState = urlFormatter.parseRequest(pRequest);
                      // holds keyword Query.
                      UrlENEQuery keywordQuery = (UrlENEQuery) pQueryBuilder.buildQuery(urlState);
                      
                      keywordQuery.setNtt(pQuestion);
                      
                      keywordQuery.setNtk("All");
                      keywordQuery.setNtx("mode+matchall");
                      
                      keywordQuery.setDx("mode+matchall");
                      keywordQuery.setD(pQuestion);
                      
                      keywordQuery.setNavAllRefinements(true);
                      if (keywordQuery.containsDimSearchQuery()) {// enable compound dimension search
                           keywordQuery.setDimSearchCompound(true);
                           // set the navigation state for the query if this is a "search within" based on the navigation descriptors
                           keywordQuery.setDimSearchNavDescriptors(keywordQuery.getNavDescriptors());
                      }
                      if(pRequest.getParameter("rootDim") != null &&
                                pRequest.getParameter("dimension") != null){
                           keywordQuery.setN(pRequest.getParameter("rootDim"));
                           keywordQuery.setNe(pRequest.getParameter("dimension"));
                      }else{
                           keywordQuery.setNty("1");
                           keywordQuery.setN("0");     
                      }
                      
                      // change once pagination is developed.
                      keywordQuery.setNavNumERecs(Constants.ITEMS_PER_PAGE);     
                      
                      if (keywordQuery.containsNavQuery()) {     // enable did you mean search
                           keywordQuery.setNavERecSearchDidYouMean(false);
                      }     
                      return keywordQuery;
                 }
            • 3. Re: constructing ENEQuery
              Mandar Shastrakar
              Query generation seems correct. What error you are getting?

              Thanks
              Mandar
              • 4. Re: constructing ENEQuery
                TimK
                Could it be that your params are backwards:
                keywordQuery.setN(pRequest.getParameter("rootDim"));
                keywordQuery.setNe(pRequest.getParameter("dimension"));
                should be
                keywordQuery.setN(pRequest.getParameter("dimension"));
                keywordQuery.setNe(pRequest.getParameter("rootDim"));
                • 5. Re: constructing ENEQuery
                  sameerdh
                  You are right tim...

                  it worked for me after replacing parameters.

                  thanks once again... :)

                  Sameer