[opencms-dev] AND, OR and LITERAL type search options using the JSP search functionality

Daniel Seidel d.seidel at alkacon.com
Tue Feb 21 12:46:28 CET 2017


Hi Rafael,

in your case, you might switch to the JSON configuration instead of 
using the XML content. You can adjust the configuration each time you 
call the search tag.

The documentation provides an example:

http://documentation.opencms.org/opencms-documentation/demos/lists-and-detail-pages-ii/index.html

And an example JSON configuration (most of the nodes are optionally). 
You can just "translate" your XML-content to that configuration.

http://documentation.opencms.org/opencms-documentation/.galleries/Documentation-Documents-for-download/cms-search-config-full.json


Best, Daniel


Am 21.02.2017 um 11:38 schrieb Cano Parra, Rafael:
>
> Daniel, thanks for your quick response!
>
> By default I have configured the query modifier as 
> “content_es:%(query) OR content_en:%(query) OR spell:%(query) OR 
> Title_prop:%(query)”. The default OR search operator is used by 
> default with this configuration.
>
> If I change this query modifier as “content_es:{!q.op=AND}%(query) OR 
> content_en:{!q.op=AND}%(query) OR spell:{!q.op=AND}%(query) OR 
> Title_prop:{!q.op=AND}%(query)”, the search operator is changed to AND.
>
> In the same way, if i change the “:{!q.op=AND}%(query)” by 
> “”%(query)”” (query between quotations), a literal search is done.
>
> However, I want the user can select the way to make the search 
> operation (AND, OR, or LITERAL), using a SELECT label with three 
> OPTION labels in the HTML search form. When the user submit the search 
> form, the results are showed.
>
> My problem is, how can I adapt, change or configure the default query 
> modifier previously configured in the formatter configuration after 
> the user submitted the form and before the formatter shows the results?
>
> I can have the modified query adapted with the search type using this 
> code:
>
> <c:set var="andQuery" value="{!q.op=AND}${param.q}" /> <%-- the 
> param.q must be fixed to obtain the search query independently of the 
> query parameter name --%>
>
> <c:set var="modifiedQuery" 
> value="${search.controller.common.config.getModifiedQuery(andQuery)}" />
>
> But I do not know how to apply this change in the search configuration 
> or status and update the search results.
>
> Best regards,
>
> *Rafael Cano Parra*
>
> Servicio de Informática
>
> Tel.: 947 52 20 13 – Ext.: 34 941
>
> rafaelcano at saludcastillayleon.es <mailto:rafaelcano at saludcastillayleon.es>
>
> *Hospital Santos Reyes*
>
> Avda. Ruperta Baraya, 6
>
> 09400 Aranda de Duero (Burgos)
>
> Tel.: 947 52 20 00 – Ext.: 34 600
>
> Fax: 947 52 20 12
>
> logo_hsry <https://www.saludcastillayleon.es/HSReyesAranda/>logo_sacyl 
> <https://www.saludcastillayleon.es/>logo_jcyl <https://www.jcyl.es/>
>
> *De:*opencms-dev-bounces at opencms.org 
> [mailto:opencms-dev-bounces at opencms.org] *En nombre de *Daniel Seidel
> *Enviado el:* lunes, 20 de febrero de 2017 13:22
> *Para:* opencms-dev at opencms.org
> *Asunto:* Re: [opencms-dev] AND, OR and LITERAL type search options 
> using the JSP search functionality
>
> Hi Rafael,
>
> you can use the local query parameters, specifying the query modifier, 
> i.e., {!q.op=AND}%(query). You might also consider using the modifier 
> to add quotes for phrase search. This might only cause problems if 
> someone enters quotes in his query.
>
> Best, Daniel.
>
> Am 20.02.2017 um 09:22 schrieb Cano Parra, Rafael:
>
>     Dear all,
>
>     I am configuring the JSP search functionality with a custom formatter.
>
>     I followed the documentation and the example formatter, with good
>     results in pagination, sorting, and search content.
>
>     However, I can not find how to implement a type search with three
>     options: search any word (OR option, it is the default behavior),
>     search all words (AND option), and search a literal phrase (words
>     between quotations).
>
>     I found that SOLR has an option to configure AND search with local
>     parameters (i.e., using “{¡q.op=AND}” attached before the search
>     query), but I can not find the way to implement this with the JSP
>     search formatter configuration, or by code in the formatter.
>
>     Also, I can not find the way to cover the search query with
>     quotations when the “search a literal phrase” option is selected,
>     without requiring the user to explicitly write the quotations in
>     the search query.
>
>     Can anyone help me, please?
>
>     Best regards,
>
>     *Rafael Cano Parra*
>
>     Servicio de Informática
>
>     Tel.: 947 52 20 13 – Ext.: 34 941
>
>     rafaelcano at saludcastillayleon.es
>     <mailto:rafaelcano at saludcastillayleon.es>
>
>     *Hospital Santos Reyes*
>
>     Avda. Ruperta Baraya, 6
>
>     09400 Aranda de Duero (Burgos)
>
>     Tel.: 947 52 20 00 – Ext.: 34 600
>
>     Fax: 947 52 20 12
>
>     logo_hsry
>     <https://www.saludcastillayleon.es/HSReyesAranda/>logo_sacyl
>     <https://www.saludcastillayleon.es/>logo_jcyl <https://www.jcyl.es/>
>
>
>     --- AVISO SOBRE CONFIDENCIALIDAD. La legislación española ampara
>     el secreto de las comunicaciones. Este correo electrónico y sus
>     anexos son estrictamente confidenciales. Si Vd. no es el
>     destinatario del mismo, por favor, notifíquenoslo inmediatamente y
>     destruya el original. No deberá copiar este mensaje ni sus anexos
>     o usarlo para propósito alguno, ni divulgar su contenido a ninguna
>     persona. ---- ---- --- WARNING ABOUT CONFIDENTIALITY. Spanish law
>     guarantees privacy in electronic communications. This message and
>     its attachments are confidential. If you are not the intended
>     recipient please, notify us immediately and destroy the original.
>     You should not copy this message or use it for any purpose, nor
>     disclose its content to any other person.
>
>
>     _______________________________________________
>
>     This mail is sent to you from the opencms-dev mailing list
>
>     To change your list options, or to unsubscribe from the list, please visit
>
>     http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
> -- 
> Kind Regards,
> Daniel.
>   
> -------------------
> Daniel Seidel
> Alkacon Software GmbH & Co. KG - The OpenCms Experts
> http://www.alkacon.com  -http://www.opencms.org      
>
>
> --- AVISO SOBRE CONFIDENCIALIDAD. La legislación española ampara el 
> secreto de las comunicaciones. Este correo electrónico y sus anexos 
> son estrictamente confidenciales. Si Vd. no es el destinatario del 
> mismo, por favor, notifíquenoslo inmediatamente y destruya el 
> original. No deberá copiar este mensaje ni sus anexos o usarlo para 
> propósito alguno, ni divulgar su contenido a ninguna persona.
>
> ---- ----
>
> --- WARNING ABOUT CONFIDENTIALITY. Spanish law guarantees privacy in 
> electronic communications. This message and its attachments are 
> confidential. If you are not the intended recipient please, notify us 
> immediately and destroy the original. You should not copy this message 
> or use it for any purpose, nor disclose its content to any other person.
>
>
> --- AVISO SOBRE CONFIDENCIALIDAD. La legislación española ampara el 
> secreto de las comunicaciones. Este correo electrónico y sus anexos 
> son estrictamente confidenciales. Si Vd. no es el destinatario del 
> mismo, por favor, notifíquenoslo inmediatamente y destruya el 
> original. No deberá copiar este mensaje ni sus anexos o usarlo para 
> propósito alguno, ni divulgar su contenido a ninguna persona. ---- 
> ---- --- WARNING ABOUT CONFIDENTIALITY. Spanish law guarantees privacy 
> in electronic communications. This message and its attachments are 
> confidential. If you are not the intended recipient please, notify us 
> immediately and destroy the original. You should not copy this message 
> or use it for any purpose, nor disclose its content to any other person.
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>

-- 
Kind Regards,
Daniel.
  
-------------------

Daniel Seidel

Alkacon Software GmbH & Co. KG - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170221/71ea2cea/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 1088 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170221/71ea2cea/attachment.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 2268 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170221/71ea2cea/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 2161 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170221/71ea2cea/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 1088 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170221/71ea2cea/attachment-0001.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 2268 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20170221/71ea2cea/attachment-0002.png>


More information about the opencms-dev mailing list