Solr search customisation

Hi,

currently i can search either in all journals or single journal

Is it possible to implement search with only 2 or more journals or search articles written by 2 authors?
if so please help me in implementing.

Hi @haq

For the search within a few journals you could try to change the Solr query parameter fq=journal_id to contain the journals you would like to search within concatenated with OR, i.e. something like: .
&fq=journal_id:("localhost-1"OR"localhost-2")… where localhost-1 and localhost-2 should be your journal IDs (= Solr installation ID from the Lucene plugin settings “-” OJS journal ID).
Thus, in OJS I would change the site search form to enable multiple journal selection, and would then try to adopt the further function calls, for the code to understand the multiple journals: first the function callbackRetrieveResults in LucenePlugin.inc.php is called and there the SolrSearchRequest object is build with the search form parameters. Then this is called: $result =& $solrWebService->retrieveResults($searchRequest, $totalResults); and in the function retrieveResults the Solr query parameters are build – $params = $this->_getSearchQueryParameters($searchRequest);. I believe there you should then build something like above (the journal IDs connection with OR).
I tested it in my local Solr installation with this manual query: http://localhost:8983/solr/ojs/search?q=title_en_US:%22Artile%20title%22&fq=journal_id:%28%22localhost-1%22OR%22localhost-2%22%29 (where “Article title” is my local article title I am looking for and the journal IDs as explained above).

Unfortunately, I don’t know what yo mean with “search articles written by 2 authors”.

I hope this helps somehow…
Best,
Bozana

hi @bozana
Thanks for the support

Actually i tried earlier with AND/OR operator it didn’t work because i had missed double quotes for journal ids. This i did by referring
https://pkp.sfu.ca/wiki/index.php?title=OJSdeSearchConcept#Query_Parser

after going through your reply i tried with OR with proper format but it is showing results only from one journal and not from another journal
where as the keyword is present in both the journals.
and if i change it to AND its showing no results.

Still its showing result from only one journal.

And apart from this i wanted to implement - multiple authors search at once.

Hi @haq

Just to double check: Did you search after a word in article title, that exists in both journals? Or after a keyword?
Every word has to be in "" and separated by OR, e.g. title_en_US:("model"OR"localization"). The same for the journal IDs: fq=journal_id:("localhost-1"OR"localhost-2")

Best,
Bozana

Hi @bozana

i got the following when i print $params of line number 1809 in function _getSearchQueryParameters(&$searchRequest) present in SolrWebService.inc.php file

Array ( [defType] => edismax [qf] => authors_txt title_en_US abstract_en_US galleyFullText_html_en_US galleyFullText_pdf_en_US galleyFullText_plain_en_US suppFiles_en_US suppFiles_txt discipline_en_US subject_en_US coverage_en_US [mm] => 1 [q] => science [spellcheck] => on [fq] => Array ( [0] => inst_id:“localhost” [1] => journal_id:“localhost-1"OR"localhost-2” ) )

it seems journal ids are in double quotes

Yes, that is true, but I am trying to figure out why is it not working for you and it works for me…

im getting results only from one journal even if the keyword is present in both the journals.
it is showing results only from first journal id i.e before OR statement and not from the following journal ids.

fq=journal_id:(“localhost-1"OR"localhost-2”)
results from journal id 1

fq=journal_id:(“localhost-2"OR"localhost-1”)
now the results from journal id 2

if the keyword is present in both the journals then it should display results from both the journals or else either one, here the keyword is present in both the journals
and i have not done any changes in my ojs installation

Hi @haq

Could you send me your Solr request URL, something like http://localhost:8983/solr/ojs/search?q=title_en_US:%22Artile%20title%22&fq=journal_id:%28%22localhost-1%22OR%22localhost-2%22%29 ?

Thanks!
Bozana

Hi @bozana

This is the url im using

http://localhost:8983/solr/ojs/select/?q=title_en_US:"science"&fq=journal_id:"localhost-1"OR"localhost-2"

but still the same results

Hi @haq

The URL above didn’t work for me as well, but with “()” around the journal IDs it did, i.e. fq=journal_id:("localhost-1"OR"localhost-2") i.e. http://localhost:8983/solr/ojs/select/?q=title_en_US:%22model%22&fq=journal_id:%28%22localhost-1%22OR%22localhost-2%22%29. Could you also test it?

Thanks!
Bozana

Hi @bozana

Thanks a lot. its working fine.

Hi @haq,

As part of the optimization of external search support for OJS, the PKP Technical Committee is looking for use cases and relevant experience with the Lucene/Solr plugin for OJS.

GitHub - ojsde/lucene: Plugin for Solr/Lucene support in OJS. or via Plugin-Gallery

We are going to organize a meeting with all the interested parties. If you are interested in sharing requirements, user experiences and use cases, please feel free to contact me.

Regards,
Dulip Withanage