You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Karl Wettin (JIRA)" <ji...@apache.org> on 2009/01/30 04:31:02 UTC

[jira] Commented: (SOLR-839) XML Query Parser support

    [ https://issues.apache.org/jira/browse/SOLR-839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12668728#action_12668728 ] 

Karl Wettin commented on SOLR-839:
----------------------------------

The patch does not parse UTF8. Not sure if it is supposed to do that by default? Below is my version of the class. It needs to pick up the contentEncoding from the properties, but I'm not sure where and how.

{code:java}
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.QParserPlugin;
import org.apache.solr.search.QParser;
import org.apache.lucene.search.Query;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.xmlparser.CorePlusExtensionsParser;
import org.apache.lucene.xmlparser.ParserException;

import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;

public class XmlQParserPlugin extends QParserPlugin {

  private String contentEncoding = "UTF8";

  public void init(NamedList args) {
  }

  public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
    return new XmlQParser(qstr, localParams, params, req);
  }


  class XmlQParser extends QParser {
    public XmlQParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
      super(qstr, localParams, params, req);
    }

    public Query parse() throws ParseException {
      CorePlusExtensionsParser parser = new CorePlusExtensionsParser(getReq().getSchema().getQueryAnalyzer(), getReq().getSchema().getSolrQueryParser(null));
      try {
        return parser.parse(new ByteArrayInputStream(getString().getBytes(contentEncoding)));
      } catch (UnsupportedEncodingException e) {
        throw new ParseException(e.getMessage());
      } catch (ParserException e) {
        throw new ParseException(e.getMessage());
      }
    }
  }

}
{code}

> XML Query Parser support
> ------------------------
>
>                 Key: SOLR-839
>                 URL: https://issues.apache.org/jira/browse/SOLR-839
>             Project: Solr
>          Issue Type: New Feature
>          Components: search
>    Affects Versions: 1.3
>            Reporter: Erik Hatcher
>            Assignee: Erik Hatcher
>             Fix For: 1.4
>
>         Attachments: lucene-xml-query-parser-2.4-dev.jar, SOLR-839.patch
>
>
> Lucene contrib includes a query parser that is able to create the full-spectrum of Lucene queries, using an XML data structure.
> This patch adds "xml" query parser support to Solr.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.