Skip to content

Phrase matched searches broken when an Enterprise Search option is disabled #79

@jakewrfoster

Description

@jakewrfoster

Description of the bug

Whenever the Enterprise Search option under "Post Search" >> "Weight results by date" is "Disabled" AND Elasticsearch Extentions' Phrase Matching feature is enabled, the following error occurs. I have not dug into yet, but my guess is that it is attempting to put a function_score clause inside of a bool query.

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
        "line": 1,
        "col": 1775
      }
    ],
    "type": "parsing_exception",
    "reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
    "line": 1,
    "col": 1775
  },
  "status": 400
}

### Steps To Reproduce

1. Activate plugin on a site with VIP Search (enterprise search)
2. Navigate to /wp-admin/admin.php?page=elasticpress
3. Open the "Post Search" accordion and disable the "Weight results by date" option
4. Enable "phrase matching" via code (hooking into `elasticsearch_extensions_config` and setting phrase matching - e.g. `$es_config->enable_phrase_matching()`
5. Perform a search with a set of double quotes around a word or phrase - e.g. `"category block"`

### Additional Information

This only appears to affect searches that have a set of double quotes around content in the search query.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingelasticsearchRequires understanding ElasticsearchphpRequires understanding PHPvip-enterprise-searchWordPress VIP Enterprise Search integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions