query-parser

Lucene QueryParser in multiple threads: synchronize or construct new each time?

无人久伴 提交于 2019-12-22 06:49:05
问题 I have a web application where users submit queries to a Lucene index. The queries are parsed by a Lucene QueryParser. I learned the hard way that QueryParser is not thread-safe. Is it better to use a single QueryParser instance, and synchronize on calls to its parse() method? Or is it better to construct a new instance for each query? (Or would I be better served by a pool of QueryParser s?) I know that in general questions like this depend on the particulars and require profiling, but maybe

What does parsing a query mean?

家住魔仙堡 提交于 2019-12-20 10:44:39
问题 Most relational databases handles a JDBC / SQL query in four steps: Parse the incoming SQL query Compile the SQL query Plan/optimize the data acquisition path Execute the optimized query / acquire and return data I want to know what does "parse the incoming query" really mean? And what does "plan/optimize data acquisition path" mean? 回答1: Parsing means examining the characters input and recognizing it as a command or statement by looking through the characters for keywords and identifiers,

What is an alternative for Lucene Query's extractTerms?

耗尽温柔 提交于 2019-12-11 18:32:29
问题 In Lucene 4.6.0 there was the method extractTerms that provided the extraction of terms from a query (Query 4.6.0). However, from Lucene 6.2.1, it does no longer exist (Query Lucene 6.2.1). Is there a valid alternative for it? What I'd need is to parse terms (and corrispondent fields) of a Query built by QueryParser. 回答1: Maybe not the best answer but one way is to use the same analyzer and tokenize the query string: Analyzer anal = new StandardAnalyzer(); TokenStream ts = anal.tokenStream(

Manipulating query using Custom Query Parser in Solr

心已入冬 提交于 2019-12-11 15:48:59
问题 I have tried to create a CustomQueryParser where I am making use of OpenNLP libraries as well. My objective is if i have a query "How many defective rims are causing failure in ABC tyres in China" I want the final query to be something like "defective rims failure tyres China" which then would go to the Analyzer for further processing. This is my code for QueryParserPlugin - package com.mycompany.lucene.search; import org.apache.solr.common.params.SolrParams; import org.apache.solr.request

Lucene error while parsing Query: Cannot parse '': Encountered “<EOF>” at line 1, column 0

夙愿已清 提交于 2019-12-11 08:28:43
问题 I want to parse some text using Lucene query parser to carry out basic text preprocessing on the texts. I used following lines of code: Analyzer analyzer = new EnglishAnalyzer(); QueryParser parser = new QueryParser("", analyzer); String text = "..."; String ret = parser.parse(QueryParser.escape(text)).toString(); But, I am getting an error: Exception in thread "main" org.apache.lucene.queryparser.classic.ParseException: Cannot parse '': Encountered "<EOF>" at line 1, column 0. 回答1: Using

Lucene queryparser with “/” in query criteria

时光总嘲笑我的痴心妄想 提交于 2019-12-08 15:27:49
问题 When I try to search for something such as "workaround/fix" within Lucene, it throws this error: org.apache.lucene.queryparser.classic.ParseException: Cannot parse 'workaround/fix': Lexical error at line 1, column 15. Encountered: <EOF> after : "/fix" at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:131) at pi.lucengine.LucIndex.main(LucIndex.java:112) Caused by: org.apache.lucene.queryparser.classic.TokenMgrError: Lexical error at line 1, column 15.

Why does Lucene QueryParser needs an Analyzer

北城余情 提交于 2019-12-06 23:51:53
问题 I'm new to Lucene and trying to parse a raw string into a Query using the QueryParser . I was wondering, why is the QueryParser.Parse() method needs an Analyzer parameter at all? If analyzing is something that has to do with querying, then an Analyzer should be specified when dealing with regular Query objects as well ( TermQuery , BooleanQuery etc), and if not, why is QueryParser requires it? 回答1: When indexing, Lucene divides the text into atomic units (tokens). During this phase many