[xwiki-devs] How can I hide attachments from search results?
We are having a problem with image attachments clogging up our search results. Say a user is searching for Orange. The topic page Orange will be ranked below an image named orange.png, as well as an image named IMAGEI68A35.png that is on a the Fruit Salad topic page. Ideally, we would be able to hide all attachments from search results. We don't want to hide attachments on topic pages-we need the images to be displayed-but we do need to hide them from search results. The problem is identical to the one posted by this user: http://jira.xwiki.org/jira/browse/XPLUCENE-63 Any suggestions? A simple bit of code I could past into a config or preference file somewhere? Any help would be greatly appreciated. Thank you very much, John Lantz Developer Advocate IdeaBlade Office: 510.596.5100 x124 Cell: 408.515.9565 Email: [email protected]<mailto:[email protected]>
John, you have to refine the "query expansion step". That's the step that is pilotted in in Main/LuceneSearch which builds a $query and $extraClause variables which obtain the results at the line below: #set($searchresults = $lucene.getSearchResults("${query}${extraClause}", '', $wikinames, $!languages)) As far as I know, if you put a word in query that, along the Lucene syntax [1] does not contain an explicit field, you obtain a query in the field ft which indexes all the words of any page content, object property or attachments (that's done in subclasses of AbstractIndexData in Lucene plugin). If you can, you should be able to change that behaviour by setting the appropriate fields, setting, for example the full name of your properties. I'm afraid I see nothing for page content. At me, I enriched the Lucene plugin by installing two back-doors: - one, called IndexDoc, to display the lndex documents' fields which helps a lot to see where to search for. - one to allow the search methods to accept Lucene query objects which is useful because I can then create a query in Groovy using the query-parser, in the default field I want, then combine it to another etc... I could try to contribute this. It is visible in i2geo's Lucene plugin (which is for an older xwiki): http://svn.activemath.org/intergeo/Platform/i2gCurriki/plugins/lucene/ . paul Le 20 janv. 2011 à 00:58, John Lantz a écrit :
We are having a problem with image attachments clogging up our search results.
Say a user is searching for Orange. The topic page Orange will be ranked below an image named orange.png, as well as an image named IMAGEI68A35.png that is on a the Fruit Salad topic page.
Ideally, we would be able to hide all attachments from search results. We don't want to hide attachments on topic pages-we need the images to be displayed-but we do need to hide them from search results.
The problem is identical to the one posted by this user: http://jira.xwiki.org/jira/browse/XPLUCENE-63
Any suggestions? A simple bit of code I could past into a config or preference file somewhere?
Any help would be greatly appreciated.
Thank you very much,
John Lantz Developer Advocate IdeaBlade Office: 510.596.5100 x124 Cell: 408.515.9565 Email: [email protected]<mailto:[email protected]>
Hi John, Yes we have a problem with the search result ranking. I remember this jira issue for example: http://jira.xwiki.org/jira/browse/XPLUCENE-8 Someone would need to look at it and provide a patch. If you're up to it feel free to provide one and we can apply it. Regarding hiding attachments altogether I'd be more hesitant to have that in the default XE. However, you should be able to filter them out I think if you edit the lucene search page. That would be a good topic to document on xwiki.org. Thanks -Vincent On Jan 20, 2011, at 12:58 AM, John Lantz wrote:
We are having a problem with image attachments clogging up our search results.
Say a user is searching for Orange. The topic page Orange will be ranked below an image named orange.png, as well as an image named IMAGEI68A35.png that is on a the Fruit Salad topic page.
Ideally, we would be able to hide all attachments from search results. We don't want to hide attachments on topic pages-we need the images to be displayed-but we do need to hide them from search results.
The problem is identical to the one posted by this user: http://jira.xwiki.org/jira/browse/XPLUCENE-63
Any suggestions? A simple bit of code I could past into a config or preference file somewhere?
Any help would be greatly appreciated.
Thank you very much,
John Lantz Developer Advocate IdeaBlade
participants (3)
-
John Lantz -
Paul Libbrecht -
Vincent Massol