BrazilianAnalyzer don't woks with any BooleanQuery
I create a method above que generate my boolean query based in many parameters. The query's on not analyzed fields works perfect in debug.
When start a search using any analyzed field with BrazilianAnalyzer, always a return empty result (zero docs). I do test in separeted solution with a unique field with Brazilian Analyzer in indexing and searching. If use a BooleanQuery and not queryparse, don't works as expected. Return empty result.
When change for StandardAnalyzer on Indexing and Serching, without alter other parts of code, works.
Re: BrazilianAnalyzer don't woks with any BooleanQuery
can you tell us more about your index side of things? Are you using
positions in the index since I see PhraseQuery in your code?
Where are you passing the text you are searching for to the
BrasilianAnalyzer, I don't see it in your code. You need to process you
text at search time too to get results.
RES: BrazilianAnalyzer don't woks with any BooleanQuery
Ok. I'm using positions at ANALYZED fields where search is by terms. The others fields, "NOT_ANALYZED", the search is by complete term, as culture code, url, document code.
The index has documents in three languages (Spanish, English and Portuguese (BR)). When perform a search, I realize filters using TermoQuery with fields "NOT_ANALYZED" and use PhraseQuery or PrefixQuery TermoQuery and added in a BoolenQuery with fields analyzed. The same code works with StandardAnalyzer. By using BrazilianAnalyzer most terms do not return a result of the stored documents with this analyzer.
In the code attached to "searchExpresion" is the phrase containing the words entered to search by the end user. I do search containing all the words, or any of the words or the whole phrase. This method makes my object "BooleanQuery" only for the content (full text).
Below is a sample of the settings of my columns to index. Some values ??are listed here with the names of the columns.
Below this code snippet, a snippet of the implementation of the search.
// Here is the method that receives and filters and query q performs abusca and treats the result
public DataSet Search(Lucene.Net.Search.Query query, Filter filter, string mainColumnContentName, Analyzer analyzer, int top, string fieldsReturn, string fieldHighlightName, string searchExpression)
Lucene.Net.Store.Directory directory = FSDirectory.Open(new DirectoryInfo(directoryPath));
IndexSearcher searcher = new IndexSearcher(directory, true);
TopDocs topDocs = searcher.Search(query, filter, top);
DataSet result = null;
if (topDocs.scoreDocs != null && topDocs.scoreDocs.Length > 0)
result = new DataSet();
DataTable docs = new DataTable("SearchResult");
for (int i = 0; i < fieldsReturn.Length; i++)
if (fieldsReturn[i] == fieldHighlightName)
if (fieldsReturn[i] != fieldHighlightName && fieldsReturn[i] != mainColumnContentName)
for (int j = 0; j < topDocs.scoreDocs.Length; j++)
Document document = searcher.Doc(topDocs.scoreDocs[j].doc);
List<string> values = new List<string>();
for (int k = 0; k < fieldsReturn.Length; k++)
if (fieldsReturn[k] == fieldHighlightName)
FastVectorHighlighter highlighter = new FastVectorHighlighter();
string fragment = highlighter.GetBestFragment(highlighter.GetFieldQuery(query), searcher.GetIndexReader(), topDocs.scoreDocs[j].doc, fieldHighlightName, NumberMaxCaractersHighlight);
if (fieldsReturn[k] == mainColumnContentName)
It's working perfectly just to other analyzers. With BrazilianAnalyzer I search the term "ferramenta" and returns nothing. There are documents in "es-ES" and "en" in the index with this term. If I search by filtering the field "DocumentCulture" with value "es-es" (field of culture not_analyzed and text field [SnowBallAnalyzer ("Spanish")]) has documents. If I filter by "pt-BR" (field of culture not_analyzed and text field [BrazilianAnalyzer]) comes nothing.
Is it a bug in [BrazilianAnalyzer]?
De: Simon Willnauer [mailto:[hidden email]]
Enviada em: quinta-feira, 12 de julho de 2012 04:48
Para: [hidden email] Assunto: Re: BrazilianAnalyzer don't woks with any BooleanQuery
can you tell us more about your index side of things? Are you using positions in the index since I see PhraseQuery in your code?
Where are you passing the text you are searching for to the BrasilianAnalyzer, I don't see it in your code. You need to process you text at search time too to get results.