Foros de discusión

Custom fulltext search portlet implementation

Patrik Holecka, modificado hace 9 años.

Custom fulltext search portlet implementation

Junior Member Mensajes: 46 Fecha de incorporación: 21/10/13 Mensajes recientes
Hi all,
I want to implement custom search portlet so I can search through attributes that are part of custom structures.
Let's say that I've made structure called "Literature" which contains attributes as author, content, title, annotations, section etc.
I want to create "advanced" search where can I select particular structure type (Literature, Verdict or Legislative), particular sections that are represented with another attribute of these structure types (for example select only literatures with section PPV or literatures with section APS) etc.

I tried to use faceted search but I didn't find out how to include these structure's attributes into query:
This is my "search" code:

SearchContext searchContext = SearchContextFactory.getInstance(httpServletRequest);

Map<string, serializable> attributes =    new HashMap<string, serializable>();
attributes.put(Field.TITLE, "some word");
attributes.put("paginationType", "regular");
searchContext.setAttributes(attributes);

Facet assetEntriesFacet = new AssetEntriesFacet(searchContext);
assetEntriesFacet.setStatic(true);            
searchContext.addFacet(assetEntriesFacet);

Facet scopeFacet = new ScopeFacet(searchContext);
scopeFacet.setStatic(true);            
searchContext.addFacet(scopeFacet);

String[] entryClassNames = { JournalArticle.class.getName() };
searchContext.setEntryClassNames(entryClassNames);

hits = FacetedSearcher.getInstance().search(searchContext);
List<document> docs = hits.toList();</document></string,></string,>


So how to include in facet search my structure specific attributes like "section" etc...

My other question is that there is a problem with punctuation. Let's say that title contains word "Právo". When I run search with word "pravo" it will bring 0 results but when I run search with "právo" it will find me somw results. Is there any workaround for search with punctuation?

Thanks,
Patrik
thumbnail
Krzysztof Gołębiowski, modificado hace 9 años.

RE: Custom fulltext search portlet implementation (Respuesta)

Liferay Master Mensajes: 549 Fecha de incorporación: 25/06/11 Mensajes recientes
I answered your question on StackOverflow.
Patrik Holecka, modificado hace 9 años.

RE: Custom fulltext search portlet implementation

Junior Member Mensajes: 46 Fecha de incorporación: 21/10/13 Mensajes recientes
Thank you again.
Patrik Holecka, modificado hace 9 años.

RE: Custom fulltext search portlet implementation

Junior Member Mensajes: 46 Fecha de incorporación: 21/10/13 Mensajes recientes
Hi, I have another question for this topic: How can I include searching by categoryId to this search? I have tried add categories array into searchContext and as a BooleanClause but nothing works. It is ignoring these categoryIds. Can you give me any advice?
sc.setCategoryIds(ids); =&gt; NOT WORKING 
BooleanClause categoryId = BooleanClauseFactoryUtil.create( sc, Field.ASSET_CATEGORY_IDS, "48472", BooleanClauseOccur.MUST.getName()); =&gt; NOT WORKING