Message Boards
DXP 7.1 Search result customization
DXP 7.1 Search result customization
Junior Member Posts: 51 Join Date: 3/29/18 Recent PostsHello,
I want to customize the search result to show certain results to appear at the top of the result when related search is performed.
Any pointer on this is appreciated.
Using DXP 7.1
Thanks
RE: DXP 7.1 Search result customization
Expert Posts: 289 Join Date: 2/13/13 Recent PostsIf you're a DXP subscriber, upgrade to 7.2 (might as well go to 7.3?) and you'll have access to a Search Tuning feature called Result Rankings
Not sure how you can homecook something like this, but I'm sure it's possible.
RE: DXP 7.1 Search result customization
Junior Member Posts: 51 Join Date: 3/29/18 Recent PostsHello Russell,
Thanks for your reply.
Since i donot have a upgrade plan as of now, So I am looking for a solution for DXP 7.1 only.
RE: DXP 7.1 Search result customization
Junior Member Posts: 51 Join Date: 3/29/18 Recent PostsHi,
I am trying to achieve this through KeywordQueryContributor. Not sure but giving a try. But after deploying the module, contribute method is not getting called.My requirement is for web contents so mentioned the indexer.class.name=com.liferay.journal.model.JournalArticle
import com.liferay.portal.kernel.search.BooleanQuery;
import com.liferay.portal.kernel.search.Field;
import com.liferay.portal.search.query.QueryHelper;
import com.liferay.portal.search.spi.model.query.contributor.KeywordQueryContributor;
import com.liferay.portal.search.spi.model.query.contributor.helper.KeywordQueryContributorHelper;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import com.liferay.portal.kernel.search.SearchContext;
@Component(
immediate = true,
property = "indexer.class.name=com.liferay.journal.model.JournalArticle",
service = KeywordQueryContributor.class
)
public class AllKeywordQueryContributor implements KeywordQueryContributor {
@Override
public void contribute(
String keywords, BooleanQuery booleanQuery,
KeywordQueryContributorHelper keywordQueryContributorHelper) {
queryHelper.addSearchLocalizedTerm(
booleanQuery, keywordQueryContributorHelper.getSearchContext(),
Field.TITLE, true);
}
@Reference
protected QueryHelper queryHelper;
}
build.gradle
dependencies {
compileOnly group: "biz.aQute.bnd",
name: "biz.aQute.bndlib", version: "3.1.0"
compileOnly group: "com.liferay", name:
"com.liferay.portal.search.api", version:
"2.0.0"
compileOnly group: "com.liferay",
name: "com.liferay.portal.search.spi", version:
"2.0.0"
compileOnly group:
"com.liferay.portal", name:
"com.liferay.portal.kernel", version: "3.0.0"
}
Any idea??