i'm using Solrj in the dao tier of my application. What i want to know is how can i get
the full query string of the request.
For example: select?q=*:*&fq=active:true
Method SolrQuery.getQuery() only returns the q=XXX part (*:* in my example)
Thx
I don't have the proper environment to test it, but SolrQuery.toString() should get you close enough.
Related
I'm testing an application that calls one API, gets a bunch of work orders, then only the work order ID's are passed to another API to display on the page.
The format they need to be in is: {"workOrderIds":["12345","123456"]}
I'm using the JSON Extractor with the following Path Expressions:
$..workOrderNumber
then I'm using the JSR223 PostProcessor and using the following script:
props.put("workOrderNumber", "${workOrderNumber}";
The problem is, that its creating the object like so when I add the variable into the POST Request body of the second request:
{"workOrderIds":["12345, 123456"]}
essentially, I just need to make sure that each value has quotations, but not sure how to make this happen. Sorry if this seems simple, I'm fairly new to QA and have spent several hours trying to figure this out.
We cannot provide a comprehensive answer without seeing the source JSON, maybe it worth trying explicitly casting the filtering result to an Integer like:
vars.put('workOrderIds', new groovy.json.JsonBuilder(new groovy.json.JsonSlurper().parse(prev.getResponseData()).findResults { entry -> entry.workOrderNumber as int }).toPrettyString())
More information:
Apache Groovy - Parsing and producing JSON
Apache Groovy - Why and How You Should Use It
I'm trying to use Apache Camel (version 2.20.0) with mybatis component.
More specifically, I have to export a large set or record from database to file.
I'd like to prevent memory issues so I want to use the option consumer.useIterator. My route is:
from("mybatis:selectItemsByDate?statementType=SelectList&consumer.useIterator=true")
.split()
.body()
.process(doSomething)
to(file:my-path-file);
but my query has in input a parameter (the starting date to get data). How should I set this parameter?
In many example on internet I saw the parameter in the body or in the header of the Exchange message but I think is possibile only if the mybatis endpoint is in a "to" method. But the option "consumer.useIterator" is working only when the enpdoint is in a "from" method.
Please help me to understand how I can set the input for my query or if this is not supported yet (in this case if you can give some hint how to implement would be great)
thank you.
Then you need to start your route from something else, like a timer or direct endpoint, and then call the mybatis endpoint in a to, where you have set that information in the message body/header you use in the mybatis query so its dynamic.
Also you should set the splitter to be in streaming mode so it walks the iterator it gets from mybatis on-demand.
I could not find an answer to this. I found the previous similar question unanswered. I'd like to use Spring data solr for queries. But #Query is insufficient for my needs. As I understood, whatever you give here becomes a q parameter to `select' handler of solr.
In my case I need to add more parameters for example sfield for a spatial search. If #Query wont cut it, I am ready to write a custom repository implementation by autowiring SolrTemplate, But then the Criteria API does not seem to let me add a raw query parameter either.
Any help/points will be greatly appreciated.
I worked around it by creating a QueryParser decorator that adds the required parameters to a parsed solr query. The QueryParser was registered using solrTemplate.registerQueryParser().
Note however that I had to do a really nasty hack to get this working, since all queries that are sent to solrTemplate.queryForPage are wrapped by a static package protected inner class in QueryBase. So my registration code above had to be in a package org.springframework.data.solr.core
The toQueryString method inside Solrj's ClientUtils class is called when the http request is formed internally. But in this process, it also encodes the commas (,) that need to be sent in the facet.pivot field.
eg . facet.pivot=A1,A2 gets sent as facet.pivot=A1%2CA2
Because of this the query returns no result.
Please suggest a mechanism to report this or any work around for the same.
Your question is about escaping/encoding the query for a solr request.
In current version of solr the toQueryString method is moved to SolrParams. But never the less "%2C" ist correct for "," in utf-8.
So most likely you have a problem on server side with unencoding the params.
Try solr in current version, because in this case you don't need to config the servlet container properly: it is now part of solr.
btw: take a look to sub-facets instead of pivot-faceting: http://yonik.com/solr-subfacets/
This is extension of my earlier question.
I'm going to create custom request handler to provide terms association mining over existing index. In order to do this I need access to Solr's IndexReader opened on default index directory.
The only way to do this I can think of is to get IndexReaderFactory by invoking SolrQueryRequest.getCore().getIndexReaderFactory(). This factory has method newReader() which seems to be what I need. But this method requires index directory as its first argument.
Here's my question: is it correct way to get IndexReader? If so, how can I get Solr's index directory? Can I access Solr configuration to find it from my code or should I go with something else?
I found an answer myself while reading LukeRequestHandler source:
SolrIndexSearcher searcher = req.getSearcher();
IndexReader reader = searcher.getReader();
So they first get searcher, and only then reader.