Foren

RE: How to search keywords using and operator

Sushma Reddy, geändert vor 12 Jahren.

How to search keywords using and operator

Junior Member Beiträge: 35 Beitrittsdatum: 28.10.10 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: How to search keywords using and operator

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: How to search keywords using and operator

New Member Beiträge: 10 Beitrittsdatum: 18.01.12 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: How to search keywords using and operator

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: How to search keywords using and operator

New Member Beiträge: 10 Beitrittsdatum: 18.01.12 Neueste Beiträge
Thank you!!!
siddhant jain, geändert vor 11 Jahren.

RE: How to search keywords using and operator

Junior Member Beiträge: 69 Beitrittsdatum: 19.03.13 Neueste Beiträge
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, geändert vor 11 Jahren.

RE: How to search keywords using and operator

Junior Member Beiträge: 69 Beitrittsdatum: 19.03.13 Neueste Beiträge
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, geändert vor 10 Jahren.

RE: How to search keywords using and operator

New Member Beiträge: 7 Beitrittsdatum: 02.08.13 Neueste Beiträge
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