On 3/23/2018 3:24 PM, Webster Homer wrote:
> I see this in the output:
> Lexical error at line 1, column 1759.  Encountered: <EOF> after :
> "/select?defType=edismax&start=0&rows=25&...
> It has basically the entire solr query which it obviously couldn't parse.
>
> solrQuery = new SolrQuery(log.getQuery());

This isn't going to work.  The string in the constructor is expected to
be query syntax -- so something like this:

company:Google AND (city:"San Jose" OR state:WA)

It has no idea what to do with a URL path and parameters.

> Is there something I'm doing wrong, or is it that the SolrQuery class
> cannot really take its toString output to make itself? Does it have a
> different serialization method that could be used?

I don't think there's any expectation that an object's toString() output
can be used as input for anything.  This is the javadoc for
Object.toString():

https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--

The emphasis there is on human readability.  It is not intended for
deserialization.  You *could* be looking at a toString() output like
SolrQuery@1d44bcfa instead of something you can actually read.

For the incomplete string shown in the error message you mentioned, you
could do:

SolrQuery q = new SolrQuery();
q.setRequestHandler("/select");
// The default handler is /select, so
// the above is actually not necessary.

q.set("defType", "edismax");
q.set("start", "0");
q.set("rows","25");
// sugar method: q.setStart(0);
// sugar method: q.setRows(25);

Thanks,
Shawn

Reply via email to