Account created on 10 March 2008, almost 17 years ago
#

Merge Requests

Recent comments

🇪🇸Spain tuwebo

Not sure about the implications of this workaround (it might break your site, take it with a grain of salt) , but it seems it is working for me if I run it before uninstalling:
drush cset --input-format=yalm views.settings display_extenders default

You might want to check the views.settings configuration before running it, executing:
drush cget views.settings

🇪🇸Spain tuwebo

Patch 3448459-3--stop-form-altering-non-extra-field-plugin-layout-builder-components.patch correctly applies and solve the issue for my use case:
Drupal: 10.3.6
Extra Field (extra_field): 8.x-2.3
Extra Field Plus: Extra Field Settings Provider (extra_field_plus): 3.0.0-beta4
Entity Print (entity_print): 8.x-2.14

I am able to properly add/edit a "View PDF" extra field using the layout builder.

Thanks @Daniel Bornman

🇪🇸Spain tuwebo

I think this might the case when using a module like entity_print, since I am running in similar issue. I'll try to provide more feedback since I've just run into it.

🇪🇸Spain tuwebo

I'm sorry my bad, it didn't work. @borrison_ what issue are you reffering to that fixed it?

🇪🇸Spain tuwebo

I am facing similar behaviour when the view has a pager, it seems like changing the view's Pager id (Pager options) to a different number than 0 (in my use case) solved the issue. Just in case could help to someone else.

🇪🇸Spain tuwebo

Just adding a patch, to check it with that code will be enough.

🇪🇸Spain tuwebo

Thinking about this issue,
Maybe we could use the Boolean Query parser to run both queries and this way combining them. I have never used it, but ti looks like it could be done. I am thinking about something like (didn't test it):
q={!bool}must=({!lucene}field1:value1) must=({!edismax qf=field2^2}value2)

🇪🇸Spain tuwebo

A potential Query parser that could fit is the Simple Query Parser https://solr.apache.org/guide/8_1/other-parsers.html#simple-query-parser

Which can be added in the solrconfig_extra.xml this way or use the PostConfigFilesGenerationEvent:
<queryParser name="simple" class="solr.SimpleQParserPlugin"/>

I think we should NOT allow WHITESPACE operator (at least), but there is an easy way to restrict it using a list of allowed ones with the parameter q.operators

The downside is we won't be able to handle Function Queries https://solr.apache.org/guide/8_1/function-queries.html

🇪🇸Spain tuwebo

A potentially Direct parse_mode handling boolean operators and grouping could look like this:

namespace Drupal\search_api_solr\Plugin\search_api\parse_mode;

use Drupal\Component\Utility\Unicode;
use Drupal\search_api\Plugin\search_api\parse_mode\Direct;

/**
 * Represents a parse mode that handles Boolean operators and grouping.
 *
 * @SearchApiParseMode(
 *   id = "direct_boolean_operators",
 *   label = @Translation("Direct query boolean operators"),
 *   description = @Translation("A direct query allowing boolean operators and grouping. Might fail if the query contains syntax errors in regard to the specific server's query syntax."),
 * )
 */
class DirectBooleanOperators extends Direct {

  /**
   * {@inheritdoc}
   */
  public function parseInput($keys) {
    // Check if input is an array.
    if (is_array($keys)) {
      // Validate each element in the array.
      foreach ($keys as $key) {
        if (!Unicode::validateUtf8($key)) {
          return '';
        }
      }
      // Convert array to string with spaces between elements.
      $keys = implode(' ', $keys);
    }
    else {
      // Validate the single string input.
      if (!Unicode::validateUtf8($keys)) {
        return '';
      }
    }

    // Test string
    // "Drupal 10 theming" AND (views OR "content types") NOT "user authentication" + performance~2 OR security^2 && (module || plugin) !deprecated

    // Boolean operators and valid symbols.
    // ['AND', 'OR', 'NOT', '&&', '||', '!', '+', '-'];

    // Valid group and scape chars.
    // ['(', ')', '\'];

    // Normalize whitespace.
    $keys = preg_replace('/\s+/u', ' ', trim($keys));

    // Handle Boolean operators and symbols, remove extra whitespaces.
    $keys = preg_replace('/\s(AND|OR|NOT|!|\|\||&&)\s/', ' $1 ', $keys);

    // Define special characters to escape.
    $escape_special_chars = ['{', '}', '[', ']', '^', '~', '*', '?', ':'];

    // Handle special characters outside of quotes.
    $keys = preg_replace_callback('/("[^"]+")|\S+/', function($matches) use ($escape_special_chars) {
      if (isset($matches[1])) {
        // This is a quoted phrase, don't modify anything inside
        return $matches[0];
      } else {
        // This is not a quoted phrase, escape only the specified special characters
        $term = $matches[0];
        foreach ($escape_special_chars as $char) {
          $term = str_replace($char, '\\' . $char, $term);
        }
        return $term;
      }
    }, $keys);


    // @TODO
    // Handle NegativeQueryProblems: Pure Negative Queries
    // https://cwiki.apache.org/confluence/display/SOLR/NegativeQueryProblems#NegativeQueryProblems-PureNegativeQueries

    return $keys;
  }
}
🇪🇸Spain tuwebo

Hello @mkalkbrenner, thank you very much for taking your time and fast response.
I will start taking a look at search_api_solr, which seems a faster approach and easier to implement, then maybe take a look at search_api which is the optimal solution.

Production build 0.71.5 2024