Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ranga Rao Bobbili
how to add search capabilities for custom entity?
February 6, 2013 12:14 PM
Answer

Ranga Rao Bobbili

Rank: Regular Member

Posts: 148

Join Date: July 20, 2007

Recent Posts

Hi All,

I have successfully integrated solr search engine to liferay 6.1 CE and able to index entities(Liferay+custom entities).

But when i retrieve data from solr search engine, i am getting zero hits. Please find the below steps and let me know my mistakes.

Step1: Custom Table script
(CREATE TABLE `libertycare`.`liberty_program` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`lpName` varchar(250) NOT NULL DEFAULT '',
`type` varchar(45) NOT NULL DEFAULT '',
`created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`companyId` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)) ;)

Step2: Created custom portlet and custom entity(LibertyProgram)service classes using ServiceBuilder tool.

Step3: Created LibertyProgramIndexer.java by extending BaseIndexer.

Step4: Added LibertyProgramIndexer class to indexer-class element inside liferay-portlet.xml.
<indexer-class>com.xerox.ghs.he.portlet.searchentity.util.LibertyProgramIndexer</indexer-class>


Step5: Created search.jsp and retrived results but getting zero hits.

Indexer indexer = IndexerRegistryUtil.getIndexer(LibertyProgram.class);
SearchContext searchContext = SearchContextFactory.getInstance(request);
searchContext.setAttribute("paginationType", "regular");
searchContext.setEnd(searchContainer.getEnd());
searchContext.setKeywords(keywords);
searchContext.setStart(searchContainer.getStart());
Hits results = indexer.search(searchContext);


Step6: Deployed custom portlet and indexed custom entity from ServerAdministration tab from controlpanel.

Step7: I am able to find the indexed data. But when i retrieve data from solr, i am getting zero hits.

Could you please provide me the valuable inputs to retrieve indexed data from solr.

Thanks in advance................

Best Regards,
Ranga Rao Bobbili
Adaequare INC
Attachment

Attachments: solr.png (205.7k)
Chirag Patadia
RE: how to add search capabilities for custom entity?
February 3, 2013 9:39 PM
Answer

Chirag Patadia

Rank: Junior Member

Posts: 29

Join Date: February 2, 2012

Recent Posts

Hi,

Can you also share snapshot which contains data inside Solr?
Ranga Rao Bobbili
RE: how to add search capabilities for custom entity?
February 4, 2013 7:25 AM
Answer

Ranga Rao Bobbili

Rank: Regular Member

Posts: 148

Join Date: July 20, 2007

Recent Posts

Chirag Patadia:
Hi,

Can you also share snapshot which contains data inside Solr?


Thank you Chirag Patadia for swift response.
I already shared solr admin schema browser page snapshot.
Let me know, do i need to share data folder screenshot.

Thanks,
Ranga Rao Bobbili
Adaequare INC
Ranga Rao Bobbili
RE: how to add search capabilities for custom entity?
February 6, 2013 12:12 PM
Answer

Ranga Rao Bobbili

Rank: Regular Member

Posts: 148

Join Date: July 20, 2007

Recent Posts

Hi All, please help me to resolve the following issue.

I am able to query solr but no results, below query showing different paramters in the solr log message. But i am not passing assetTagNames, groupid,scopreGroupId, comments,description,properties,title,url,userName,content etc... parameters in the solr console log message.

My Query
Indexer indexer = IndexerRegistryUtil.getIndexer(LibertyProgram.class);
SearchContext searchContext = SearchContextFactory.getInstance(request);
searchContext.setCompanyId(10154);
searchContext.setKeywords(keywords);
Hits results = indexer.search(searchContext);



Solr Log Message
INFO: [] webapp=/solr path=/select params={hl.fragsize=80&fl=score&hl.snippets=3&q=%2B(%2B((%2B(entryClassName:com.xerox.ghs.he.portlet.searchentity.model.LibertyProgram)))
+%2B(%2B(groupId:10180)+%2B(scopeGroupId:10180)))+%2B(assetCategoryTitles:Xerox*+assetTagNames:Xerox*+comments:xerox+
content:xerox+description:xerox+properties:xerox+title:xerox+url:xerox+userName:Xerox*)+%2BcompanyId:10154&
facet.limit=-1&hl.fl=content&hl.fl=content_en_US&hl.fl=title&hl.fl=title_en_US&wt=javabin&hl=true&rows=0&version=1} hits=0 status=0 QTime=48


Liferay experts,friends, please let me know the solution to resolve above issue.

Thanks in advance...............

Best Regards,
Ranga Rao Bobbili
Adaequare INC
Oliver Bayer
RE: how to add search capabilities for custom entity?
February 8, 2013 3:41 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 867

Join Date: February 18, 2009

Recent Posts

Hi Ranga,

I've never used Solr so I'm not really an expert but maybe you can use my hints anyhow to narrow it down:
  • Please check if Solr has some indexed contents.
  • Do you have a tool similar to luke (to check the lucene index) to search directy at Solr level?
  • If yes use the search query and check if Solr is returning any results.
  • If not simplify the search query (e.g. by removing search parameters) until you will get a result.
  • Now compare the search queries to know where the error occurs: at Solr or in Liferay (that means in your search class).

HTH Oli
Ranga Rao Bobbili
RE: how to add search capabilities for custom entity?
April 10, 2013 12:53 PM
Answer

Ranga Rao Bobbili

Rank: Regular Member

Posts: 148

Join Date: July 20, 2007

Recent Posts

Thanks Oliver Bayer for quick response.

I have fixed all issues related to Solr search for custom entity. The main issue is with solr-web community endition plugins.

Thanks & Regards,
Ranga Rao Bobbili
Adaequare INC