No attachments appear in search results

Hi, whenever a search is performed in may wiki, results in attachments are initially not included in search results.

after clicking “reset” in the facets tab, search results in attachments are displayed.

i want to configure xwiki, so that search results in attachments are displayed by default, without modifiying facets.

how can this be achieved?

We do search in attachments by default but the search results are indeed pages (documents) by default, meaning that a page is returned if one of its attachments are matching the search query. You can test this by searching for “logo” which should return the Sandbox page because it has an attachment matching the search query.

If you want to have attachments directly as search results by default then you need to edit the Main.SolrSearchConfig page and modify the facetQuery by replacing:

'type': 'DOCUMENT',

with

'type': ['DOCUMENT', 'ATTACHMENT'],

sorry for this noob question.
after 2 hours i gave up to locate Main.SolrSearchConfig on my system.
can you give me a hint where to search?
its a ubuntu i18.04 system

Hi!

Sry to bump this old thread, but I found it because I have a similar problem.

I want to do a search in XWiki only in the content of pages. But unfortunately, I also get search results for attachments of the pages. Filter is “f_type=DOCUMENT”

This seems to be the reason:

This is not as expected. If I want to search attachements, I would add attachements as search criteria.

How can I prevent XWiki from having this behaviour? How can I actual only search for words in page contents?

It’s a wiki page, which you can access with a URL like this <server>/xwiki/bin/view/Main/SolrSearchConfig

Check Main.SolrSearchConfig. Look for queryFields, which specifies the fields that are matched, grouped by results type.

Okay, so it is not facetQuery, what I’m looking for …

You mean this here?

  'queryFields': {
    'DOCUMENT': 'title^10.0 name^10.0
                 doccontent^2.0
                 objcontent^0.4 filename^0.4 attcontent^0.4 doccontentraw^0.4
                 author_display^0.08 creator_display^0.08
                 comment^0.016 attauthor_display^0.016 spaces^0.016',
    'ATTACHMENT': 'filename^5.0 attcontent attauthor_display^0.2',
    'OBJECT': 'objcontent',
    'OBJECT_PROPERTY': 'propertyvalue'
  },

I deleted “filename^0.4 attcontent^0.4” from DOCUMENT and now, there is a complete strange behaviour:

  • when using f_type=DOCUMENT, I got 2 results (was 10 before, seems to be fine):
  • if I remove f_type, I got 10 results for result type “document” and 10 results for result type attachement :grimacing:
  • → it should also be 2 for document type in that case … ?!

PS: Do I need to delete the fields also from phraseFields, bigramPhraseFields and so on?
I don’t understand, what the entries phaseFields (and so on) stands for.

You probably want to remove attauthor_display^0.016 as well.

Yes, that’s my expectation as well.

I think so, at least for consistency.

phaseFields maps to pf parameter from Extended DisMax (eDisMax) Query Parser :: Apache Solr Reference Guide . bigramPhraseFields maps to pf2 and trigramPhraseFields maps to pf3.

Thanks your explanations.

I could reproduce the wrong (?) behaviour in a minimalistic example.
So here is a bug report:

(hopefully, this is the correct Jira project)

I commented on the reported issue. Unfortunately I don’t think this is a bug but rather a limitation (by design) that prevents you from cleanly configure the search to not match attachments when looking for wiki pages (without some unexpected side effects).

Thanks for the feedback, even though we don’t really know how to deal with the fact right now :wink:
Probably we have to live with it …