<p dir="auto">It would be useful to be able to return the net overlap/disjoint areas on a geo_shape query, so as to determine similarity of the queried shape to the indexed document.</p>
<p dir="auto">First, the use case:</p>
<p dir="auto">To ensure a single, tested, artifact to be installed across the fleet, including all plugins needed, our build process roughly works like this:</p>
<ul dir="auto">
<li>Grab the version of ES as a debian package</li>
<li>Extract this debian package in a temp dir</li>
<li>cd into this directory and run: <code class="notranslate">bin/plugin install ...</code></li>
<li>go back to the temp dir, and repackage as debian package</li>
</ul>
<p dir="auto">The reason for the debian package is that the init scripts for ES do a lot of work (setting ulimit, users, groups, etc), and we don't want to duplicate that and maintain it; otherwise we'd just use the tarball.</p>
<p dir="auto">This process worked fine with 1.5.x, but starting 1.6, the 'plugin' command can no longer find the needed config files. Here are the specific issues:</p>
<ol dir="auto">
<li>
<p dir="auto">Even though it finds 'CONF_DIR' just fine, it insists on setting 'CONF_FILE' separately, and does not use the same heuristics as for 'CONF_DIR'.</p>
</li>
<li>
<p dir="auto">It now requires /etc/default/elasticsearch to be present to run, which requires an installed version, or another override.</p>
</li>
</ol>
<p dir="auto">The workaround is now to do this, which is ugly and prone to breakage going forward:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ES_INCLUDE=`pwd`/etc/default/elasticsearch CONF_FILE=`pwd`/etc/elasticsearch/elasticsearch.yaml CONF_DIR=`pwd`/etc/elasticsearch  usr/share/elasticsearch/bin/plugin  -h"><pre class="notranslate"><code class="notranslate">$ ES_INCLUDE=`pwd`/etc/default/elasticsearch CONF_FILE=`pwd`/etc/elasticsearch/elasticsearch.yaml CONF_DIR=`pwd`/etc/elasticsearch  usr/share/elasticsearch/bin/plugin  -h
</code></pre></div>
<p dir="auto">The full diff below, to illustrate the offending parts:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="diff elasticsearch-1.{5.2,6.0}/usr/share/elasticsearch/bin/plugin
23a26,62
&gt; # Sets the default values for elasticsearch variables used in this script
&gt; if [ -z &quot;$CONF_DIR&quot; ]; then
&gt;   CONF_DIR=&quot;/etc/elasticsearch&quot;
&gt;
&gt;   if [ -z &quot;$CONF_FILE&quot; ]; then
&gt;     CONF_FILE=&quot;$CONF_DIR/elasticsearch.yml&quot;
&gt;   fi
&gt; fi
&gt;
&gt; if [ -z &quot;$CONF_FILE&quot; ]; then
&gt;   CONF_FILE=&quot;/etc/elasticsearch/elasticsearch.yml&quot;
&gt; fi
&gt;
&gt; # The default env file is defined at building/packaging time.
&gt; # For a deb package, the value is &quot;/etc/default/elasticsearch&quot;.
&gt; ES_ENV_FILE=&quot;/etc/default/elasticsearch&quot;
&gt;
&gt; # If an include is specified with the ES_INCLUDE environment variable, use it
&gt; if [ -n &quot;$ES_INCLUDE&quot; ]; then
&gt;     ES_ENV_FILE=&quot;$ES_INCLUDE&quot;
&gt; fi
&gt;
&gt; # Source the environment file
&gt; if [ -n &quot;$ES_ENV_FILE&quot; ]; then
&gt;
&gt;   # If the ES_ENV_FILE is not found, try to resolve the path
&gt;   # against the ES_HOME directory
&gt;   if [ ! -f &quot;$ES_ENV_FILE&quot; ]; then
&gt;       ES_ENV_FILE=&quot;$ELASTIC_HOME/$ES_ENV_FILE&quot;
&gt;   fi
&gt;
&gt;   . &quot;$ES_ENV_FILE&quot;
&gt;   if [ $? -ne 0 ]; then
&gt;       echo &quot;Unable to source environment file: $ES_ENV_FILE&quot; &gt;&amp;2
&gt;       exit 1
&gt;   fi
&gt; fi
48c87,96
&lt; exec &quot;$JAVA&quot; $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home=&quot;$ES_HOME&quot; $properties -cp &quot;$ES_HOME/lib/*&quot; org.elasticsearch.plugins.PluginManager $args

---
&gt; # check if properties already has a config file or config dir
&gt; if [ -e &quot;$CONF_DIR&quot; ]; then
&gt;   case &quot;$properties&quot; in
&gt;     *-Des.default.path.conf=*|*-Des.path.conf=*)
&gt;     ;;
&gt;     *)
&gt;       properties=&quot;$properties -Des.default.path.conf=$CONF_DIR&quot;
&gt;     ;;
&gt;   esac
&gt; fi
49a98,110
&gt; if [ -e &quot;$CONF_FILE&quot; ]; then
&gt;   case &quot;$properties&quot; in
&gt;     *-Des.default.config=*|*-Des.config=*)
&gt;     ;;
&gt;     *)
&gt;       properties=&quot;$properties -Des.default.config=$CONF_FILE&quot;
&gt;     ;;
&gt;   esac
&gt; fi
&gt;
&gt; export HOSTNAME=`hostname -s`
&gt;
&gt; exec &quot;$JAVA&quot; $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home=&quot;$ES_HOME&quot; $properties -cp &quot;$ES_HOME/lib/*&quot; org.elasticsearch.plugins.PluginManager $args"><pre class="notranslate"><code class="notranslate">diff elasticsearch-1.{5.2,6.0}/usr/share/elasticsearch/bin/plugin
23a26,62
&gt; # Sets the default values for elasticsearch variables used in this script
&gt; if [ -z "$CONF_DIR" ]; then
&gt;   CONF_DIR="/etc/elasticsearch"
&gt;
&gt;   if [ -z "$CONF_FILE" ]; then
&gt;     CONF_FILE="$CONF_DIR/elasticsearch.yml"
&gt;   fi
&gt; fi
&gt;
&gt; if [ -z "$CONF_FILE" ]; then
&gt;   CONF_FILE="/etc/elasticsearch/elasticsearch.yml"
&gt; fi
&gt;
&gt; # The default env file is defined at building/packaging time.
&gt; # For a deb package, the value is "/etc/default/elasticsearch".
&gt; ES_ENV_FILE="/etc/default/elasticsearch"
&gt;
&gt; # If an include is specified with the ES_INCLUDE environment variable, use it
&gt; if [ -n "$ES_INCLUDE" ]; then
&gt;     ES_ENV_FILE="$ES_INCLUDE"
&gt; fi
&gt;
&gt; # Source the environment file
&gt; if [ -n "$ES_ENV_FILE" ]; then
&gt;
&gt;   # If the ES_ENV_FILE is not found, try to resolve the path
&gt;   # against the ES_HOME directory
&gt;   if [ ! -f "$ES_ENV_FILE" ]; then
&gt;       ES_ENV_FILE="$ELASTIC_HOME/$ES_ENV_FILE"
&gt;   fi
&gt;
&gt;   . "$ES_ENV_FILE"
&gt;   if [ $? -ne 0 ]; then
&gt;       echo "Unable to source environment file: $ES_ENV_FILE" &gt;&amp;2
&gt;       exit 1
&gt;   fi
&gt; fi
48c87,96
&lt; exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $args

---
&gt; # check if properties already has a config file or config dir
&gt; if [ -e "$CONF_DIR" ]; then
&gt;   case "$properties" in
&gt;     *-Des.default.path.conf=*|*-Des.path.conf=*)
&gt;     ;;
&gt;     *)
&gt;       properties="$properties -Des.default.path.conf=$CONF_DIR"
&gt;     ;;
&gt;   esac
&gt; fi
49a98,110
&gt; if [ -e "$CONF_FILE" ]; then
&gt;   case "$properties" in
&gt;     *-Des.default.config=*|*-Des.config=*)
&gt;     ;;
&gt;     *)
&gt;       properties="$properties -Des.default.config=$CONF_FILE"
&gt;     ;;
&gt;   esac
&gt; fi
&gt;
&gt; export HOSTNAME=`hostname -s`
&gt;
&gt; exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $args
</code></pre></div>