Fórum

How to search keywords using and operator

Sushma Reddy, modificado 13 Anos atrás.

How to search keywords using and operator

Junior Member Postagens: 35 Data de Entrada: 28/10/10 Postagens Recentes
Hi All,
I am using liferay 6.0.5 ,I want to search my webcontent with word or with a string.I am using this code

Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);
SearchContext searchContext = SearchContextFactory.getInstance(request);
searchContext.setKeywords("Hai Sushma");
searchContext.setAndSearch(true);
Hits hits=indexer.search(searchContext);

But it is getting the contents with "Hai" and with "sushma"
Is there any way that i can perform 'and' operation between two keywords,which gives articles containing exactly "Hai Sushma".

Thanks,
Sushma
thumbnail
Hitoshi Ozawa, modificado 13 Anos atrás.

RE: How to search keywords using and operator

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
But it is getting the contents with "Hai" and with "sushma"


You don't want the phrase broken into words. I think that was in the Lucene settings.
The default StandardAnalyzer does this.
#
# Set the default analyzer used for indexing and retrieval.
#
#lucene.analyzer=org.apache.lucene.analysis.br.BrazilianAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.cjk.CJKAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.cz.CzechAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.nl.DutchAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.fr.FrenchAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.de.GermanAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.KeywordAnalyzer
#lucene.analyzer=org.apache.lucene.index.memory.PatternAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.PerFieldAnalyzerWrapper
#lucene.analyzer=org.apache.lucene.analysis.ru.RussianAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.SimpleAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.snowball.SnowballAnalyzer
lucene.analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.StopAnalyzer
#lucene.analyzer=org.apache.lucene.analysis.WhitespaceAnalyzer

Try changing to "KeywordAnalyzer" to not break words.
Vlad Kuzmyk, modificado 12 Anos atrás.

RE: How to search keywords using and operator

New Member Postagens: 10 Data de Entrada: 18/01/12 Postagens Recentes
What is the file name and where I can find it?

I looked for lucene and could not find the lines above

Please help,
Thank you.
thumbnail
Hitoshi Ozawa, modificado 12 Anos atrás.

RE: How to search keywords using and operator

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
Those settings are in portal-impl.jar. You can overwrite them by creating portal-ext.properties in the ROOT\WEB-INF\classes directory.
Vlad Kuzmyk, modificado 12 Anos atrás.

RE: How to search keywords using and operator

New Member Postagens: 10 Data de Entrada: 18/01/12 Postagens Recentes
Thank you!!!
siddhant jain, modificado 11 Anos atrás.

RE: How to search keywords using and operator

Junior Member Postagens: 69 Data de Entrada: 19/03/13 Postagens Recentes
i am new to liferay so i do not know much about it...
can you please describe in brief what is all this code and where i have to set "keywordanalyzer"...
siddhant jain, modificado 11 Anos atrás.

RE: How to search keywords using and operator

Junior Member Postagens: 69 Data de Entrada: 19/03/13 Postagens Recentes
got a simple way instestedemoticon

just added

keywords=keywords.replace(" ","+");
to replace the space character with AND operator in search.jsp...emoticon

thanks to lucene search for providing AND operation directly...
Erick Sanematsu, modificado 10 Anos atrás.

RE: How to search keywords using and operator

New Member Postagens: 7 Data de Entrada: 02/08/13 Postagens Recentes
Hello,

Where did you put this piece of code in search.jsp?
I'm using Liferay 6.1 GA3, and I tried via EXT to override lucene's configuration (override beans from search-spring.xml, since in Liferay 6.1 GA3 there are no more lucene's configuration on portal-ext.properties), but I messed up with the search.
Before that I tried this solution, I put this code after String keywords = ParamUtil.getString(request, "keywords"); on search.jsp, but there are no effect at all on the search, even if I put programmatically a word to keywords. I tried to put this code as well after keywords = keywords.replace(/^\s+|\s+$/, ''); on functions, but both solutions didn't work for me.

Thanks.
Erick