Package org.apache.solr.search

Examples of org.apache.solr.search.QParser


      if (rb.getQueryString() == null) {
        rb.setQueryString( qString);
      }

      try {
        QParser parser = QParser.getParser(rb.getQueryString(), defType, rb.req);
        rb.setQuery( parser.getQuery() );
        rb.setSortSpec( parser.getSort(true) );
        rb.setQparser(parser);

       
        String[] fqs = params.getParams(CommonParams.FQ);
        if (fqs!=null && fqs.length!=0) {
          List<Query> filters = rb.getFilters();
          if (filters==null) {
            filters = new ArrayList<Query>();
            rb.setFilters( filters );
          }
          for (String fq : fqs) {
            if (fq != null && fq.trim().length()!=0) {
              QParser fqp = QParser.getParser(fq, null, rb.req);
              filters.add(fqp.getQuery());
            }
          }
        } 
      } catch (ParseException e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
View Full Code Here


  @Test
  public void testSimple() {
    try {
      SolrNLSQParserPlugin solrNLSQParserPlugin = new SolrNLSQParserPlugin();
      LocalSolrQueryRequest request = testHarness.getRequestFactory("standard", 0, 10).makeRequest("q", "\"people working at Google Amsterdam office\"", "debugQuery", "true");
      QParser nlsQParser = solrNLSQParserPlugin.createParser("people working at Google Amsterdam office", new
              MapSolrParams(new HashMap<String, String>()), new MapSolrParams(new HashMap<String, String>()),
              request);
      Query q = nlsQParser.parse();
      assertNotNull(q);
      System.out.println(q.toString());
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getLocalizedMessage());
View Full Code Here

     * @param request The current request
     * @return this
     * @throws ParseException If parsing the groupQueryString failed
     */
    public Builder setQuery(String groupQueryString, SolrQueryRequest request) throws ParseException {
      QParser parser = QParser.getParser(groupQueryString, null, request);
      this.queryString = groupQueryString;
      return setQuery(parser.getQuery());
    }
View Full Code Here

    }

    @Override
    public QParser createParser(String qstr, SolrParams localParams,
      SolrParams params, SolrQueryRequest req) {
  return new QParser(qstr, localParams, params, req) {
      @Override
      public Query parse() throws ParseException {
    try {
        String file = localParams.get(QueryParsing.V);
View Full Code Here

  }

  public static List<Query> getFilterQuery(SolrQueryRequest req,
      String tablename) throws ParseException {
    List<Query> filters = new ArrayList<Query>();
    QParser all = QParser.getParser("*:*", null, req);
    filters.add(all.getQuery());
    String[] fqs = req.getParams()
        .getParams(HigoJoinUtils.getFq(tablename));
    if (fqs != null && fqs.length != 0) {
      for (String fq : fqs) {
        if (fq != null && fq.trim().length() != 0) {
          QParser fqp = QParser.getParser(fq, null, req);
          filters.add(fqp.getQuery());
        }
      }
    }
   
    return filters;
View Full Code Here

    rb.doHighlights = highlighter.isHighlightingEnabled(params);
    if(rb.doHighlights){
      String hlq = params.get(HighlightParams.Q);
      if(hlq != null){
        try {
          QParser parser = QParser.getParser(hlq, null, rb.req);
          rb.setHighlightQuery(parser.getHighlightQuery());
        } catch (ParseException e) {
          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
        }
      }
    }
View Full Code Here

    }

    @Override
    public QParser createParser(String qstr, SolrParams localParams,
      SolrParams params, SolrQueryRequest req) {
  return new QParser(qstr, localParams, params, req) {
      @Override
      public Query parse() throws ParseException {
    try {
        String file = localParams.get(QueryParsing.V);
        String field=localParams.get(QueryParsing.F);
View Full Code Here

    }

    @Override
    public QParser createParser(String qstr, SolrParams localParams,
      SolrParams params, SolrQueryRequest req) {
  return new QParser(qstr, localParams, params, req) {
      @Override
      public Query parse() throws ParseException {
    try {
        String contains = localParams.get(QueryParsing.V);
        String field=localParams.get(QueryParsing.F);
View Full Code Here

    answerTypeMap = new HashMap<String, String>();//<co id="qqpp.atm"/>
    answerTypeMap.put("L", "NE_LOCATION");
    answerTypeMap.put("T", "NE_TIME|NE_DATE");
    answerTypeMap.put("P", "NE_PERSON");
    answerTypeMap.put("O", "NE_ORGANIZATION");
    QParser qParser;
    if (params.getBool(QAParams.COMPONENT_NAME, false) == true //<co id="qqpp.explainif"/>
            && qStr.equals("*:*") == false) {
      AnswerTypeClassifier atc =
              new AnswerTypeClassifier(model, probs, atcg);//<co id="qqpp.atc"/>
      Parser parser = new ChunkParser(chunker, tagger);//<co id="qqpp.parser"/>
View Full Code Here

   * recursion.
   */
  @Override
  public QParser subQuery(final String q, final String defaultType)
  throws ParseException {
    final QParser nestedParser = super.subQuery(q, defaultType);
    final NamedList<Object> params = nestedParser.getParams().toNamedList();
    params.remove("nested");
    nestedParser.setParams(SolrParams.toSolrParams(params));
    return nestedParser;
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.search.QParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.