Missing parantheses between conjuctions in solr query

Created on 9 October 2024, 2 months ago

Problem/Motivation

When constructing Solr queries by concatenating multiple conjunction terms, parentheses are missing around individual conditions. This results in queries that do not group conditions as intended, potentially leading to incorrect query results. For example, the current query format is params = q=+field=value+AND++field2=value2+, but it should be formatted as q=(field=value)AND(field2=value2) to ensure proper execution and result accuracy.

Steps to reproduce

  1. Install Search API Solr Devel Module and look into the Solr request array and rawData item.
  2. Construct a Advanced Search that includes multiple conditions using conjunctions (e.g., AND, OR).
  3. Observe the absence of parentheses around individual conditions in the constructed query string and unnecessary plus signs.
  4. Execute the query and note any discrepancies or unexpected results due to the lack of proper condition grouping.

Proposed resolution

The proposed resolution involves modifying the query construction logic to automatically include parentheses around each condition when concatenating them with conjunctions and remove spaces to avoid plus signs. May replace implode with string concatenation.

Remaining tasks

  • Review the current query construction code to identify where the concatenation logic can be improved.
  • Implement the changes to automatically add parentheses around conditions when they are concatenated.
  • Conduct thorough testing with various query scenarios to ensure that the new logic correctly handles all cases.
🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇩🇪Germany rnsrk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024