Request for HttpSolrServer.
SolrQuery solrQuery = new SolrQuery(); solrQuery.setQuery(q); QueryResponse queryResponse = solrServer.query(solrQuery);
I need to create a solr request, something like "author: * user_inputed_text * title: * user_inputed_text *" I need something like PreparedStatement, but I could not find something like this in the solrj library. How to build a query that will not contain injections? How to make the line entered by the user - \ user_input_text \ safe?
I create a query using concatenation. When I have, for example, this code:
public String buildQuery(String userInputedText) { String query = "author:*" + userInputedText + "* OR title:*" + userInputedText + "*"; }
Then the user can enter some subquery and get results that are not limited. For example, the entered line: "OR title:". Thus, the entire query will look like this: author: * OR title: * OR title: * OR title: *
In this case, the user receives all the results (they are not limited) and passes to the author of the template: *? * OR title: *? *.
source share