10up / ElasticPress

A fast and flexible search and query engine for WordPress.
https://elasticpress.io
GNU General Public License v2.0
1.25k stars 313 forks source link

Add instructions for autosuggest #1504

Open tott opened 5 years ago

tott commented 5 years ago

When enabling autosuggest an endpoint url needs to be configured but there are no instructions given on how to determine these settings.

Describe the solution you'd like It would be good to try to determine and suggest a reasonable default or provide documentation on how to determine this url.

Designs https://i.imgur.com/06t6UlY.png

fabianmarz commented 4 years ago

Just some short notes on how I managed to set up autosuggest on EP 3.3:

Endpoint URL: /ep-autosuggest

Nginx Config:

location /ep-autosuggest {
  # only allow POST requests
  limit_except POST {
    deny all;
  }

  # Perform our request
  rewrite ^/ep-autosuggest(.*) $1/_search break;
  proxy_set_header Host $host;

  # Use the URL of the server here
  proxy_pass http://localhost:9200;
  return 403;
}

The Nginx config is a slightly modified version of the one from: https://github.com/10up/elasticpress-autosuggest

ocountry commented 4 years ago

Just some short notes on how I managed to set up autosuggest on EP 3.3:

Endpoint URL: /ep-autosuggest

Nginx Config:

location /ep-autosuggest {
  # only allow POST requests
  limit_except POST {
    deny all;
  }

  # Perform our request
  rewrite ^/ep-autosuggest(.*) $1/_search break;
  proxy_set_header Host $host;

  # Use the URL of the server here
  proxy_pass http://localhost:9200;
  return 403;
}

The Nginx config is a slightly modified version of the one from: https://github.com/10up/elasticpress-autosuggest

@fabianmarz I tried your snippet, but this one only returns 403 with body "User is not authorized to perform this action".

My ES is hosted on AWS with open security policies.

Any suggestion ?

fabianmarz commented 4 years ago

@ocountry, unfortunately I'm not familiar with AWS and thus cannot point out how to fix it. Is ES AWS running on nginx solely or is it used as proxy with apache? Are you sure the policies are configured correctly? Seems the error message is caused by this.