掲示板

Where to put custom Facet Implementation?

thumbnail
10年前 に Tim Myerscough によって更新されました。

Where to put custom Facet Implementation?

New Member 投稿: 8 参加年月日: 13/03/01 最新の投稿
Hi.

I am using Liferay 6.2.

I would like to create a custom search facet: com.example.MySearchFacet, to filter search results based on categories for a particular vocabulary.

I have created a hook containing my custom code and JSPs.

I have added the search portlet with the advanced configuration:

{"facets": [
{
        "displayStyle": "filtered_asset_categories",
        "static": false,
        "weight": 1.1,
        "order": "OrderHitsDesc",
        "data": {
            "displayStyle": "list",
            "maxTerms": 10,
            "frequencyThreshold": 1,
            "showAssetCount": true,
            "includes": [
            	"v1"
            ]
        },
        "className": "com.example.MySearchFacet",
        "label": "category",
        "fieldName": "assetCategoryTitles"
    }
]}


However, when I perform the search, I get a ClassNotFoundException thrown:


16:41:28,921 ERROR [http-bio-8080-exec-9][IncludeTag:129] Current URL /web/guest/search?_3_formDate=1394440884427&p_p_id=3&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&_3_struts_action=%2Fsearch%2Fsearch&_3_cur=1&_3_format=&_3_keywords=test&_3_clearSearch.x=8&_3_clearSearch.y=14 generates exception: javax.servlet.ServletException: java.lang.ClassNotFoundException: com.example.MySearchFacet
java.lang.ClassNotFoundException: com.example.MySearchFacet
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at java.lang.Class.forName(Class.java:190)
        at com.liferay.portal.kernel.search.facet.util.FacetFactoryUtil.create(FacetFactoryUtil.java:40)
        at org.apache.jsp.html.portlet.search.search_jsp._jspService(search_jsp.java:1079)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)


So where do I need to add my custom code?

Is it possible to add it as a hook, or does it have to be an EXT plugin?
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: Where to put custom Facet Implementation? (回答)

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
The code has to run within the Liferay webapp, so you can either deploy the jar as a global jar (i.e. lib/ext in tomcat) or as an EXT plugin.
thumbnail
10年前 に Tim Myerscough によって更新されました。

RE: Where to put custom Facet Implementation?

New Member 投稿: 8 参加年月日: 13/03/01 最新の投稿
Hi David.

I was coming to that conclusion that was the case. I was just hoping to avoid it. emoticon

Regards

Tim
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: Where to put custom Facet Implementation?

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
EXTs are nothing to be afraid of. Limit your EXT to those things you cannot do with a normal plugin and it won't get unwieldy and unmanageable.
thumbnail
10年前 に Tim Myerscough によって更新されました。

RE: Where to put custom Facet Implementation?

New Member 投稿: 8 参加年月日: 13/03/01 最新の投稿
Indeed, but EXTs add a number of complications which make them undesirable:
* Development is slower due to the need for restarts
* Deployment/redeployment of an EXT is non-trivial
thumbnail
10年前 に Tim Myerscough によって更新されました。

RE: Where to put custom Facet Implementation?

New Member 投稿: 8 参加年月日: 13/03/01 最新の投稿
Considering the Search portlet configuration allows for the specification of custom classes, it would be great if the feature was refactored to allow for the packaging of a hook for custom search implementations.
thumbnail
10年前 に Tim Myerscough によって更新されました。

RE: Where to put custom Facet Implementation?

New Member 投稿: 8 参加年月日: 13/03/01 最新の投稿
I have raised https://issues.liferay.com/browse/LPS-44990 to cover the feature request to manage Facet implementations as a hook.

Vote if you wanna go faster!
thumbnail
10年前 に Ray Augé によって更新されました。

RE: Where to put custom Facet Implementation?

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
Hey guys,

You sort of need EXT for this as it stands.

However, here is the first issue (not related to the error, but will cause an issue even if your code above worked)
1) your Facet impl has to extend one of these classes (rather than just implementing the interface):
- com.liferay.portal.kernel.search.facet.MultiValueFacet
- com.liferay.portal.kernel.search.facet.RangeFacet
- com.liferay.portal.kernel.search.facet.SimpleFacet
Otherwise it won't pass the necessary info into the search engine impl. We'll have to make a note of that in the Javadocs.

2) the JSP of the search portlet is executing in the core and knows nothing about the classes in your plugin

If there was a ticket for the classLoading issue we might be able to address it.

I could see us adding a JSON field which declares the name of the plugin context of a Facet class. If the field exists, and is not null, then load an instance of the class from the registered classLoader for that plugin context.
thumbnail
10年前 に Tim Myerscough によって更新されました。

RE: Where to put custom Facet Implementation?

New Member 投稿: 8 参加年月日: 13/03/01 最新の投稿
Thanks for the insight Ray.

My custom Facet extends com.liferay.portal.kernel.search.facet.MultiValueFacet, so that should be ok.

Something that would enable me to specify context used for class loading would be great.

I'll update the ticket I raised to cover the points you raised.
7年前 に Venkat N によって更新されました。

RE: Where to put custom Facet Implementation?

New Member 投稿: 11 参加年月日: 12/02/14 最新の投稿
Hi Tim Myerscough,

Did you get chance to implement the above scenario please provide the snippet of code for me. I have to implement similar kind of Custom fecest search in my assignment.
Please help me .....

-----
Best Regards,
Venkat N.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Where to put custom Facet Implementation?

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Venkat N:
I have to implement similar kind of Custom fecest search in my assignment.


Homework assignment or work assignment? Either way it should probably be your work you're submitting and not Tim's...