lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcelo Neves" <marcelo.ne...@xgen.com.br>
Subject BrazilianAnalyzer don't woks with any BooleanQuery
Date Wed, 11 Jul 2012 15:32:16 GMT
Hi all,

 

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. 

 

Could anyone help me?

[Code]

 

protected virtual BooleanQuery GetExpressionBooleanQuery(string
searchExpression, SearchModeEnum searchMode, bool searchDocumentHistory,
bool onlyDocumentHistory)

{

                if (string.IsNullOrEmpty(searchExpression))

                {

                               return null;

                }

 

                BooleanQuery queryWords = new BooleanQuery();

                PhraseQuery phrase = new PhraseQuery();

                string[] expressions = null;

 

                expressions = searchExpression.ToLower().Replace("\"",
"").Split(' ');

                for (int i = 0; i < expressions.Length; i++)

                {

                               if
(!string.IsNullOrEmpty(expressions[i].Trim()))

                               {

                                               if (expressions.Length > 1)

                                               {

                                                               switch
(searchMode)

                                                               {

 
case SearchModeEnum.ExactPhrase:

 
if (!onlyDocumentHistory)

 
{

 
phrase.Add(new Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT,
expressions[i].Trim()), i);

 
}

 
if (searchDocumentHistory)

 
{

 
phrase.Add(new Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT_NODEXML,
expressions[i].Trim()), i);

 
}

 
break;

 
case SearchModeEnum.AnyWord:

 
if (!onlyDocumentHistory)

 
{

 
queryWords.Add(new BooleanClause(new TermQuery(new
Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT,
expressions[i].Trim())), BooleanClause.Occur.SHOULD));

 
}

 
if (searchDocumentHistory)

 
{

 
queryWords.Add(new BooleanClause(new TermQuery(new
Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT_NODEXML,
expressions[i].Trim())), BooleanClause.Occur.SHOULD));

 
}

 
break;

 
case SearchModeEnum.AllWords:

 
if (!onlyDocumentHistory)

 
{

 
queryWords.Add(new BooleanClause(new TermQuery(new
Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT,
expressions[i].Trim())), BooleanClause.Occur.MUST));

 
}

 
if (searchDocumentHistory)

 
{

 
queryWords.Add(new BooleanClause(new TermQuery(new
Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT_NODEXML,
expressions[i].Trim())), BooleanClause.Occur.MUST));

 
}

 
break;

 
default:

 
break;

                                                               }

                                               }

                                               else

                                               {

                                                               if
(!onlyDocumentHistory)

                                                               {

 
queryWords.Add(new BooleanClause(new TermQuery(new
Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT,
expressions[i].Trim())), BooleanClause.Occur.MUST));

                                                               }

                                                               if
(searchDocumentHistory)

                                                               {

 
queryWords.Add(new BooleanClause(new TermQuery(new
Term(ColumnsIndexedDocuments.COLUMN_DOCUMENTCONTENT_NODEXML,
expressions[i].Trim())), BooleanClause.Occur.MUST));

                                                               }

                                               }

                               }

                }

                if (phrase.GetTerms().Length > 0)

                {

                               queryWords.Add(new BooleanClause(phrase,
BooleanClause.Occur.MUST));

                }

                return queryWords;

}

 

[/Code]

 

I wait for help. Please!

 

Thanks!

 

Descrição: marcelo-neves

 


Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message