Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Sushma Reddy
How to search keywords using and operator
21. April 2011 09:19
Antwort

Sushma Reddy

Rang: Junior Member

Nachrichten: 35

Eintrittsdatum: 28. Oktober 2010

Neue 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
Hitoshi Ozawa
RE: How to search keywords using and operator
21. April 2011 17:01
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7990

Eintrittsdatum: 23. März 2010

Neue 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
RE: How to search keywords using and operator
8. März 2012 14:02
Antwort

Vlad Kuzmyk

Rang: New Member

Nachrichten: 10

Eintrittsdatum: 18. Januar 2012

Neue 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.
Hitoshi Ozawa
RE: How to search keywords using and operator
8. März 2012 15:28
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7990

Eintrittsdatum: 23. März 2010

Neue 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
RE: How to search keywords using and operator
9. März 2012 06:54
Antwort

Vlad Kuzmyk

Rang: New Member

Nachrichten: 10

Eintrittsdatum: 18. Januar 2012

Neue Beiträge

Thank you!!!
siddhant jain
RE: How to search keywords using and operator
21. März 2013 22:28
Antwort

siddhant jain

Rang: Junior Member

Nachrichten: 52

Eintrittsdatum: 19. März 2013

Neue 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
RE: How to search keywords using and operator
21. März 2013 23:13
Antwort

siddhant jain

Rang: Junior Member

Nachrichten: 52

Eintrittsdatum: 19. März 2013

Neue 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
RE: How to search keywords using and operator
27. Februar 2014 04:07
Antwort

Erick Sanematsu

Rang: New Member

Nachrichten: 7

Eintrittsdatum: 2. August 2013

Neue 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