Foros de discusión

How to filter using "defaultLangaugeId" field in Journal Article Document?

Vishnu S Kumar, modificado hace 6 años.

How to filter using "defaultLangaugeId" field in Journal Article Document?

Regular Member Mensajes: 131 Fecha de incorporación: 28/07/17 Mensajes recientes
We have a custom search portlet and various custom web content structures. We are able to filter the search results in the IndexerPostProcessor using all fields except the "defaultLanguageId" field in the document. Why is it not working? When we add a filtering in this field, we won't get any hits back.


ex:
		Filter filter = booleanFilter.addTerm("defaultLanguageId", "fr_CA");
				booleanFilter.add(filter, BooleanClauseOccur.MUST);
thumbnail
Andrew Jardine, modificado hace 6 años.

RE: How to filter using "defaultLangaugeId" field in Journal Article Docume

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Hi Vishnu,

Can you try using a BooleanClause? and then adding that clause to the search context? Something like this --


        // create the base context
        HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest);
        SearchContext searchContext = SearchContextFactory.getInstance(request);

         // create the clause
         BooleanClause defaultLanguageClause  = BooleanClauseFactoryUtil.create(Field.DEFAULT_LANGUAGE_ID, LocaleUtil.CANADA_FRENCH, BooleanClauseOccur.MUST.toString());

         // add the clause to the search context
         searchContext.setBooleanClauses(new BooleanClause[]{defaultLanguageClause});



... then get your indexer, and pass the context. I use this all the time to build queries and even customize some of the out of the box stuff. Hopefully it will work for you as well.
Vishnu S Kumar, modificado hace 6 años.

RE: How to filter using "defaultLangaugeId" field in Journal Article Docume

Regular Member Mensajes: 131 Fecha de incorporación: 28/07/17 Mensajes recientes
Thanks, Andrew, but unfortunately It didn't work. It filtered out all the documents and didn't get any hits back.
thumbnail
Andrew Jardine, modificado hace 6 años.

RE: How to filter using "defaultLangaugeId" field in Journal Article Docume

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Strange. So the next question would be.. are you sure you have content with that value? I only ask because I've done it before... So sure they it was there but after using Luke realized it was not emoticon.

If you are sure, then at this point I would say, please share your code.