我試圖通過AssetEntries實現自定義搜索portlet。目前AssetEntryQuery不允許使用關鍵字進行搜索。我試圖通過FacetedSearcher進行搜索。按關鍵字搜索似乎沒問題。但是,當我試圖通過AssetTagNames搜索時Liferay searchContext按AssetTags和關鍵字搜索
searchContext.setAssetTagNames(assetTagNames)
它根本不起作用。 這裏是我的一段代碼
SearchContext searchContext = new SearchContext();
Facet assetEntriesFacet = new AssetEntriesFacet(searchContext);
assetEntriesFacet.setStatic(true);
searchContext.addFacet(assetEntriesFacet);
/*MultiValueFacet multiValueFacet=new MultiValueFacet(searchContext);
multiValueFacet.setFieldName("assetTagNames");
multiValueFacet.setStatic(false);
searchContext.addFacet(multiValueFacet);*/
searchContext.setCompanyId(themeDisplay.getCompanyId());
String []assetTagNames=new String[1];
assetTagNames[0]= assetTagName;
searchContext.setAssetTagNames(assetTagNames);
searchContext.setKeywords(keywords);
String[] entryClassName = {JournalArticle.class.getName()};
searchContext.setEntryClassNames(entryClassName);
Indexer indexer = FacetedSearcher.getInstance();
// searchContext.setAndSearch(true);
Hits hits = indexer.search(searchContext);
System.out.println("Hits: " + hits.getLength());
的要求 searchKeyword結果查詢:key1key1 assetTagName:sometag
+(+(companyId:1) +((+(entryClassName:com.liferay.portlet.journal.model.JournalArticle) +(status:0)))) +(assetCategoryTitles:*key1key1* assetCategoryTitles_en_US:*key1key1* assetTagNames:*key1key1* comments:key1key1 content:key1key1 description:key1key1 properties:key1key1 title:key1key1 url:key1key1 userName:*key1key1* classPK:key1key1 content_en_US:key1key1 description_en_US:key1key1 entryClassPK:key1key1 title_en_US:key1key1 type:key1key1)
正如你看到的ASSETTAG不應用於查詢。 我已經試圖通過
searchContext.setAttribute("assetTagNames",assetTagName);
進行設置,並評論MultiValueFacet代碼,但王氏沒有結果。 爲了進一步我需要通過dateRange和類別搜索。有沒有人有任何想法?