问:
Why isn't my Slider Puzzle game working properly?
I'm not very good at JS, but I want to make a slider puzzle game but instead of an image I want every slideable block to be a word, right now the grid is 25 x 25. The words will form a poem and the person that "plays" the little game has to be able to rearrange all the words in a different order so he can make his own poem.

I looked up some other slide puzzles and tried to copy them, but the problem is that I'm not working with an image but seperate words. So when a block is moved the word doesn't transfer with it.

function swapTiles(cell1, cell2) {
  var temp = document.getElementById(cell1).className;
  document.getElementById(cell1).className = document.getElementById(cell2).className;
  document.getElementById(cell2).className = temp;
}

function shuffle() {
  //Use nested loops to access each cell of the 3x3 grid
  for (var row = 1; row <= 5; row++) { //For each row of the 3x3 grid
    for (var column = 1; column <= 5; column++) { //For each column in this row

      var row2 = Math.floor(Math.random() * 5 + 1); //Pick a random row from 1 to 3
      var column2 = Math.floor(Math.random() * 5 + 1); //Pick a random column from 1 to 3

      swapTiles("cell" + row + column, "cell" + row2 + column2); //Swap the look & feel of both cells
    }
  }
}

function clickTile(row, column) {
  var cell = document.getElementById("cell" + row + column);
  var tile = cell.className;
  if (tile != "tile25") {
    //Checking if white tile on the right
    if (column < 5) {
      if (document.getElementById("cell" + row + (column + 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column + 1));
        return;
      }
    }
    //Checking if white tile on the left
    if (column > 1) {
      if (document.getElementById("cell" + row + (column - 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column - 1));
        return;
      }
    }
    //Checking if white tile is above
    if (row > 1) {
      if (document.getElementById("cell" + (row - 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row - 1) + column);
        return;
      }
    }
    //Checking if white tile is below
    if (row < 5) {
      if (document.getElementById("cell" + (row + 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row + 1) + column);
        return;
      }
    }
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: 'Playfair Display', serif;
  -webkit-user-select: none;
  /* Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+/Edge */
  user-select: none;
  /* Standard */
}

body {
  background: white;
}

.tile1,
.tile2,
.tile3,
.tile4,
.tile5,
.tile6,
.tile7,
.tile8,
.tile9,
.tile10,
.tile11,
.tile12,
.tile13,
.tile14,
.tile15,
.tile16,
.tile17,
.tile18,
.tile19,
.tile20,
.tile21,
.tile22,
.tile23,
.tile24 {
  display: table-cell;
  width: 120px;
  height: 120px;
  text-align: center;
  vertical-align: middle;
  background-color: lightgrey;
  font-size: 10pt;
  cursor: pointer;
  border: 2px solid white;
}

.tile25 {
  background-color: white;
  display: table-cell;
  width: 120px;
  height: 120opx;
  opacity: 0.4;
  text-align: center;
  vertical-align: middle;
}

#table {
  display: table;
}

#row1,
#row2,
#row3,
#row4,
#row5 {
  display: table-row;
}</code>```

<link href="https://fonts.googleapis.com/css?family=Playfair+Display&display=swap" rel="stylesheet">

BANANEN

PRUIMEN

ADVOCADOS

PAPRIKAS

RADIJZEN

BLAUWE BESSEN

ABRIKOZEN

VIJGEN

WITTE DRUIVEN

MANGOS

KIWIS

APPELS

PEREN

MANDARIJNEN

RODE DRUIVEN

ACEROLAS

BRAMEN

COURGETTES

FRAMBOZEN

KOKOSNOTEN

KERSEN

PAPAJAS

MELOENEN

DADELS

<button onClick="shuffle();">New Game</button>```

CodePen

Anybody has an idea?

答:
It's just missing the textContent to be swapped. Just it's added in the below code.

function swapTiles(cell1, cell2) {
 var elem1 = document.getElementById(cell1),
  elem2 = document.getElementById(cell2);

  var tempClass = elem1.className;
  var tempText = elem1.textContent;

  elem1.className = elem2.className;
  elem1.textContent = elem2.textContent;

  elem2.className = tempClass;
  elem2.textContent = tempText;
}

function shuffle() {
  //Use nested loops to access each cell of the 3x3 grid
  for (var row = 1; row <= 5; row++) { //For each row of the 3x3 grid
    for (var column = 1; column <= 5; column++) { //For each column in this row

      var row2 = Math.floor(Math.random() * 5 + 1); //Pick a random row from 1 to 3
      var column2 = Math.floor(Math.random() * 5 + 1); //Pick a random column from 1 to 3

      swapTiles("cell" + row + column, "cell" + row2 + column2); //Swap the look & feel of both cells
    }
  }
}

function clickTile(row, column) {
  var cell = document.getElementById("cell" + row + column);
  var tile = cell.className;
  if (tile != "tile25") {
    //Checking if white tile on the right
    if (column < 5) {
      if (document.getElementById("cell" + row + (column + 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column + 1));
        return;
      }
    }
    //Checking if white tile on the left
    if (column > 1) {
      if (document.getElementById("cell" + row + (column - 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column - 1));
        return;
      }
    }
    //Checking if white tile is above
    if (row > 1) {
      if (document.getElementById("cell" + (row - 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row - 1) + column);
        return;
      }
    }
    //Checking if white tile is below
    if (row < 5) {
      if (document.getElementById("cell" + (row + 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row + 1) + column);
        return;
      }
    }
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: 'Playfair Display', serif;
  -webkit-user-select: none;
  /* Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+/Edge */
  user-select: none;
  /* Standard */
}

body {
  background: white;
}

.tile1,
.tile2,
.tile3,
.tile4,
.tile5,
.tile6,
.tile7,
.tile8,
.tile9,
.tile10,
.tile11,
.tile12,
.tile13,
.tile14,
.tile15,
.tile16,
.tile17,
.tile18,
.tile19,
.tile20,
.tile21,
.tile22,
.tile23,
.tile24 {
  display: table-cell;
  width: 120px;
  height: 120px;
  text-align: center;
  vertical-align: middle;
  background-color: lightgrey;
  font-size: 10pt;
  cursor: pointer;
  border: 2px solid white;
}

.tile25 {
  background-color: white;
  display: table-cell;
  width: 120px;
  height: 120opx;
  opacity: 0.4;
  text-align: center;
  vertical-align: middle;
}

#table {
  display: table;
}

#row1,
#row2,
#row3,
#row4,
#row5 {
  display: table-row;
}</code>```

BANANEN

PRUIMEN

ADVOCADOS

PAPRIKAS

RADIJZEN

BLAUWE BESSEN

ABRIKOZEN

VIJGEN

WITTE DRUIVEN

MANGOS

KIWIS

APPELS

PEREN

MANDARIJNEN

RODE DRUIVEN

ACEROLAS

BRAMEN

COURGETTES

FRAMBOZEN

KOKOSNOTEN

KERSEN

PAPAJAS

MELOENEN

DADELS

  <button onClick="shuffle();">New Game</button>

```

Body:
I'm not very good at JS, but I want to make a slider puzzle game but instead of an image I want every slideable block to be a word, right now the grid is 25 x 25. The words will form a poem and the person that "plays" the little game has to be able to rearrange all the words in a different order so he can make his own poem.

I looked up some other slide puzzles and tried to copy them, but the problem is that I'm not working with an image but seperate words. So when a block is moved the word doesn't transfer with it.

function swapTiles(cell1, cell2) {
  var temp = document.getElementById(cell1).className;
  document.getElementById(cell1).className = document.getElementById(cell2).className;
  document.getElementById(cell2).className = temp;
}

function shuffle() {
  //Use nested loops to access each cell of the 3x3 grid
  for (var row = 1; row <= 5; row++) { //For each row of the 3x3 grid
    for (var column = 1; column <= 5; column++) { //For each column in this row

      var row2 = Math.floor(Math.random() * 5 + 1); //Pick a random row from 1 to 3
      var column2 = Math.floor(Math.random() * 5 + 1); //Pick a random column from 1 to 3

      swapTiles("cell" + row + column, "cell" + row2 + column2); //Swap the look & feel of both cells
    }
  }
}

function clickTile(row, column) {
  var cell = document.getElementById("cell" + row + column);
  var tile = cell.className;
  if (tile != "tile25") {
    //Checking if white tile on the right
    if (column < 5) {
      if (document.getElementById("cell" + row + (column + 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column + 1));
        return;
      }
    }
    //Checking if white tile on the left
    if (column > 1) {
      if (document.getElementById("cell" + row + (column - 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column - 1));
        return;
      }
    }
    //Checking if white tile is above
    if (row > 1) {
      if (document.getElementById("cell" + (row - 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row - 1) + column);
        return;
      }
    }
    //Checking if white tile is below
    if (row < 5) {
      if (document.getElementById("cell" + (row + 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row + 1) + column);
        return;
      }
    }
  }

}

* {
  font-family: 'Playfair Display', serif;
  -webkit-user-select: none;
  /* Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+/Edge */
  user-select: none;
  /* Standard */
}

body {
  background: white;
}

.tile1,
.tile2,
.tile3,
.tile4,
.tile5,
.tile6,
.tile7,
.tile8,
.tile9,
.tile10,
.tile11,
.tile12,
.tile13,
.tile14,
.tile15,
.tile16,
.tile17,
.tile18,
.tile19,
.tile20,
.tile21,
.tile22,
.tile23,
.tile24 {
  display: table-cell;
  width: 120px;
  height: 120px;
  text-align: center;
  vertical-align: middle;
  background-color: lightgrey;
  font-size: 10pt;
  cursor: pointer;
  border: 2px solid white;
}

.tile25 {
  background-color: white;
  display: table-cell;
  width: 120px;
  height: 120opx;
  opacity: 0.4;
  text-align: center;
  vertical-align: middle;
}

#table {
  display: table;
}

#row1,
#row2,
#row3,
#row4,
#row5 {
  display: table-row;
}

<link href="https://fonts.googleapis.com/css?family=Playfair+Display&display=swap" rel="stylesheet">

BANANEN

PRUIMEN

ADVOCADOS

PAPRIKAS

RADIJZEN

BLAUWE BESSEN

ABRIKOZEN

VIJGEN

WITTE DRUIVEN

MANGOS

KIWIS

APPELS

PEREN

MANDARIJNEN

RODE DRUIVEN

ACEROLAS

BRAMEN

COURGETTES

FRAMBOZEN

KOKOSNOTEN

KERSEN

PAPAJAS

MELOENEN

DADELS

<button onClick="shuffle();">New Game</button>

CodePen

Anybody has an idea?

Body:
It's just missing the textContent to be swapped. Just it's added in the below code.

function swapTiles(cell1, cell2) {
 var elem1 = document.getElementById(cell1),
  elem2 = document.getElementById(cell2);

  var tempClass = elem1.className;
  var tempText = elem1.textContent;

  elem1.className = elem2.className;
  elem1.textContent = elem2.textContent;

  elem2.className = tempClass;
  elem2.textContent = tempText;
}

function shuffle() {
  //Use nested loops to access each cell of the 3x3 grid
  for (var row = 1; row <= 5; row++) { //For each row of the 3x3 grid
    for (var column = 1; column <= 5; column++) { //For each column in this row

      var row2 = Math.floor(Math.random() * 5 + 1); //Pick a random row from 1 to 3
      var column2 = Math.floor(Math.random() * 5 + 1); //Pick a random column from 1 to 3

      swapTiles("cell" + row + column, "cell" + row2 + column2); //Swap the look & feel of both cells
    }
  }
}

function clickTile(row, column) {
  var cell = document.getElementById("cell" + row + column);
  var tile = cell.className;
  if (tile != "tile25") {
    //Checking if white tile on the right
    if (column < 5) {
      if (document.getElementById("cell" + row + (column + 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column + 1));
        return;
      }
    }
    //Checking if white tile on the left
    if (column > 1) {
      if (document.getElementById("cell" + row + (column - 1)).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + row + (column - 1));
        return;
      }
    }
    //Checking if white tile is above
    if (row > 1) {
      if (document.getElementById("cell" + (row - 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row - 1) + column);
        return;
      }
    }
    //Checking if white tile is below
    if (row < 5) {
      if (document.getElementById("cell" + (row + 1) + column).className == "tile25") {
        swapTiles("cell" + row + column, "cell" + (row + 1) + column);
        return;
      }
    }
  }

}

* {
  font-family: 'Playfair Display', serif;
  -webkit-user-select: none;
  /* Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+/Edge */
  user-select: none;
  /* Standard */
}

body {
  background: white;
}

.tile1,
.tile2,
.tile3,
.tile4,
.tile5,
.tile6,
.tile7,
.tile8,
.tile9,
.tile10,
.tile11,
.tile12,
.tile13,
.tile14,
.tile15,
.tile16,
.tile17,
.tile18,
.tile19,
.tile20,
.tile21,
.tile22,
.tile23,
.tile24 {
  display: table-cell;
  width: 120px;
  height: 120px;
  text-align: center;
  vertical-align: middle;
  background-color: lightgrey;
  font-size: 10pt;
  cursor: pointer;
  border: 2px solid white;
}

.tile25 {
  background-color: white;
  display: table-cell;
  width: 120px;
  height: 120opx;
  opacity: 0.4;
  text-align: center;
  vertical-align: middle;
}

#table {
  display: table;
}

#row1,
#row2,
#row3,
#row4,
#row5 {
  display: table-row;
}

<div>
  <div id="table">
    <div id="row1">
      <div id="cell11" class="tile1" onClick="clickTile(1,1);">BANANEN</div>
      <div id="cell12" class="tile2" onClick="clickTile(1,2);">PRUIMEN</div>
      <div id="cell13" class="tile3" onClick="clickTile(1,3);">ADVOCADOS</div>
      <div id="cell14" class="tile4" onClick="clickTile(1,4);">PAPRIKAS</div>
      <div id="cell15" class="tile5" onClick="clickTile(1,5);">RADIJZEN</div>
    </div>
    <div id="row2">
      <div id="cell21" class="tile6" onClick="clickTile(2,1);">BLAUWE BESSEN</div>
      <div id="cell22" class="tile7" onClick="clickTile(2,2);">ABRIKOZEN</div>
      <div id="cell23" class="tile8" onClick="clickTile(2,3);">VIJGEN</div>
      <div id="cell24" class="tile9" onClick="clickTile(2,4);">WITTE DRUIVEN</div>
      <div id="cell25" class="tile10" onClick="clickTile(2,5);">MANGOS</div>
    </div>
    <div id="row3">
      <div id="cell31" class="tile11" onClick="clickTile(3,1);">KIWIS</div>
      <div id="cell32" class="tile12" onClick="clickTile(3,2);">APPELS</div>
      <div id="cell33" class="tile13" onClick="clickTile(3,3);">PEREN</div>
      <div id="cell34" class="tile14" onClick="clickTile(3,4);">MANDARIJNEN</div>
      <div id="cell35" class="tile15" onClick="clickTile(3,5);">RODE DRUIVEN</div>
    </div>
    <div id="row4">
      <div id="cell41" class="tile16" onClick="clickTile(4,1);">ACEROLAS</div>
      <div id="cell42" class="tile17" onClick="clickTile(4,2);">BRAMEN</div>
      <div id="cell43" class="tile18" onClick="clickTile(4,3);">COURGETTES</div>
      <div id="cell44" class="tile19" onClick="clickTile(4,4);">FRAMBOZEN</div>
      <div id="cell45" class="tile20" onClick="clickTile(4,5);">KOKOSNOTEN</div>
    </div>
    <div id="row5">
      <div id="cell51" class="tile21" onClick="clickTile(5,1);">KERSEN</div>
      <div id="cell52" class="tile22" onClick="clickTile(5,2);">PAPAJAS</div>
      <div id="cell53" class="tile23" onClick="clickTile(5,3);">MELOENEN</div>
      <div id="cell54" class="tile24" onClick="clickTile(5,4);">DADELS</div>
      <div id="cell55" class="tile25" onClick="clickTile(5,5);"></div>
    </div>
  </div>
  <button onClick="shuffle();">New Game</button>
</div>


来源: stackexchange

问:
Is it possible to use polygon data annotation to perform tensorflow object detection?
My problem is not exactly annotate data using polygon, circle or line, it's how to use these annotated data to gerenate a ".tfrecord" file and perform an object detection. The tutorials I saw use rectangle annotation, like these: taylor swift detection raccon detection

It would be a great one for me if the objects I want to detect (pipelines) were not too close.

Example of rectangle drawn in PASCAL VOC format:

```<code><bndbox>
    <xmin>82</xmin>
    <xmax>172</xmax>
    <ymin>108</ymin>
    <ymax>146</ymax>
</bndbox>
</code>```

Is there a way to add a "mask" to highlight some part of this bounding box?

If it's something unclear, please let me know.

答:
You can go for instance segmentation instead of object detection if your objects are very close to each other, there you can use polygons to generate masks and bounding boxes to train the model.

Consider this well presented and easy to use repository for mask-rcnn(kind of instance segmentation)

https://github.com/matterport/Mask_RCNN

check this for lite weight mask-rcnn

ContentLicense: CC BY-SA 4.0

Body:
My problem is not exactly annotate data using polygon, circle or line, it's how to use these annotated data to gerenate a ".tfrecord" file and perform an object detection. The tutorials I saw use rectangle annotation, like these: taylor swift detection raccon detection

It would be a great one for me if the objects I want to detect (pipelines) were not too close.

Example of rectangle drawn in PASCAL VOC format:

<bndbox>
    <xmin>82</xmin>
    <xmax>172</xmax>
    <ymin>108</ymin>
    <ymax>146</ymax>
</bndbox>

Is there a way to add a "mask" to highlight some part of this bounding box?

If it's something unclear, please let me know.


问:
How to style(html and css) emails body in PHP using sendgrid to send email?
I am using sendgrid i want to style my sent Emails but at the email they are showing raw code i do not know why.
Is there somewhere i am doing incorrect or something?
This is the code i wrote ...

```<code>require 'vendor/autoload.php';
$email = new \SendGrid\Mail\Mail();
$email->setFrom("my email address");
$email->setSubject("Welcome");
$email->addTo($EmailAddress);
//Below code where i am having issues
$email->addContent("text/plain", "<img src='Assets/images/logo.png'> Welcome To my channel...");
$sendgrid = new \SendGrid('your api code');
$sendgrid->send($email);
</code>```

答:
Your content type is wrong. You have to set it to text/html:

```<code>$email->addContent("text/html", "<img src='Assets/images/logo.png'> Welcome To my channel...");
</code>```

Otherwise it will not be rendered as html even if you write html.

Body:
I am using sendgrid i want to style my sent Emails but at the email they are showing raw code i do not know why.
Is there somewhere i am doing incorrect or something?
This is the code i wrote ...

require 'vendor/autoload.php';
$email = new \SendGrid\Mail\Mail();
$email->setFrom("my email address");
$email->setSubject("Welcome");
$email->addTo($EmailAddress);
//Below code where i am having issues
$email->addContent("text/plain", " Welcome To my channel...");
$sendgrid = new \SendGrid('your api code');
$sendgrid->send($email);

Body:
Your content type is wrong. You have to set it to text/html:

$email->addContent("text/html", "<img src='Assets/images/logo.png'> Welcome To my channel...");

Otherwise it will not be rendered as html even if you write html.


问:
MariaDB / MySQL querys are case sensitive?
I just want to know if that querys are case sensitive or not. Are the same these querys?

```<code>SELECT * FROM Users WHERE login="john";
SELECT * FROM Users WHERE login="John";
SELECT * FROM Users WHERE login="JOHN";
SELECT * FROM Users WHERE login="jOHn";
</code>```

I have tried that on my console and all of them worked, but I want to be sure of that if I would use Hibernate or anything else.

Thanks!

答:
Just an example from my Linux ( Debian 10 ) Box in MariaDB (Ver.10.3.18-MariaDB-0+deb10u1 ).May be helpful for someone !!</p>

```<code>MariaDB [niffdb]> select * from account_heads where head_desc="Fuel";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
|       1 | Fuel      |
+---------+-----------+
1 row in set (0.004 sec)

MariaDB [niffdb]> select * from account_heads where head_desc="FUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
|       1 | Fuel      |
+---------+-----------+
1 row in set (0.001 sec)

MariaDB [niffdb]> select * from account_heads where head_desc="fUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
|       1 | Fuel      |
+---------+-----------+
1 row in set (0.001 sec)

MariaDB [niffdb]>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I just want to know if that querys are case sensitive or not. Are the same these querys?

SELECT * FROM Users WHERE login="john";
SELECT * FROM Users WHERE login="John";
SELECT * FROM Users WHERE login="JOHN";
SELECT * FROM Users WHERE login="jOHn";

I have tried that on my console and all of them worked, but I want to be sure of that if I would use Hibernate or anything else.

Thanks!

Body:
Just an example from my Linux ( Debian 10 ) Box in MariaDB (Ver.10.3.18-MariaDB-0+deb10u1 ).May be helpful for someone !!

MariaDB [niffdb]> select * from account_heads where head_desc="Fuel";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
|       1 | Fuel      |
+---------+-----------+
1 row in set (0.004 sec)

MariaDB [niffdb]> select * from account_heads where head_desc="FUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
|       1 | Fuel      |
+---------+-----------+
1 row in set (0.001 sec)

MariaDB [niffdb]> select * from account_heads where head_desc="fUEL";
+---------+-----------+
| head_id | head_desc |
+---------+-----------+
|       1 | Fuel      |
+---------+-----------+
1 row in set (0.001 sec)

MariaDB [niffdb]>


问:
check or change keyboard typing language from server or client side
how can we check or change keyboard typing language from server or client side ?</p>

答:
You can't control this from the browser (or server).

Would you really want any random website to be able to change your typing language without your intervention?


问:
TimeFormat always from specific timezone
I have problem with date format I create App where I cant format time from current locale but always from specific locale UTC+1 or specific state, but I dont know how.

```<code>SimpleDateFormat("d.M.yyyy  HH:mm", Locale.getDefault()).format(Date(date))
</code>```

i need set locale or timezone like constant which not depend on physical position or phone settings.

I have data always in UTC-0 but I need transform it to UTC+1 (or other) and show to users.

Thanks for any help

For time sync I use TrueTime library

答:
Is this what you're looking for?</p>

```<code>DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d.M.yyyy  HH:mm");

LocalDateTime localDateTime = LocalDateTime.parse(dateTimeString, formatter);

ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, ZoneId.of("UTC+1"));
</code>```

Body:
I have problem with date format I create App where I cant format time from current locale but always from specific locale UTC+1 or specific state, but I dont know how.

SimpleDateFormat("d.M.yyyy  HH:mm", Locale.getDefault()).format(Date(date))

i need set locale or timezone like constant which not depend on physical position or phone settings.

I have data always in UTC-0 but I need transform it to UTC+1 (or other) and show to users.

Thanks for any help

For time sync I use TrueTime library

Body:
Is this what you're looking for?

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d.M.yyyy  HH:mm");

LocalDateTime localDateTime = LocalDateTime.parse(dateTimeString, formatter);

ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, ZoneId.of("UTC+1"));


问:
Require ajax request for route group
I'm having a route group that looks following:

web.php

```<code>Route::group( ['middleware' => 'auth', 'prefix' => 'ajax'],
    function() {
        Route::post( 'checkTheName', function( Request $request ) {
            return response()->json( 'Something important' );
        } );
    }
);
</code>```

Is this possible with Laravel to check whether incoming request is an AJAX request for all routes in a group (and if not, throw eg. a 404 status)? I find it kinda pointless checking it within every child route post. Thats why I would like to make a global check if request is within the route group scope.

Using Laravel 5.5

答:
The correct way to do this, is to return the next variable in every middleware handle. Above method with abort_unless will actually not work in Laravel 6. Have not tested on previous versions.

```<code>if(!$request->ajax()) {
    abort(404);
} else {
    return $next($request);
}
</code>```

Even better is to return 401 instead of 404, since it probably is an unauthorized request.

Title: Require ajax request for route group

Body:
I'm having a route group that looks following:

web.php

Route::group( ['middleware' => 'auth', 'prefix' => 'ajax'],
    function() {
        Route::post( 'checkTheName', function( Request $request ) {
            return response()->json( 'Something important' );
        } );
    }
);

Is this possible with Laravel to check whether incoming request is an AJAX request for all routes in a group (and if not, throw eg. a 404 status)? I find it kinda pointless checking it within every child route post. Thats why I would like to make a global check if request is within the route group scope.

Using Laravel 5.5

Body:
The correct way to do this, is to return the next variable in every middleware handle. Above method with abort_unless will actually not work in Laravel 6. Have not tested on previous versions.

if(!$request->ajax()) {
    abort(404);
} else {
    return $next($request);
}

Even better is to return 401 instead of 404, since it probably is an unauthorized request.


问:
R: How to match strings of variable length in dataframe columns with different row numbers?
I have two data frames in R with different number of rows. df1 has 2 columns with 12000+ rows and df2 has <200 rows. Both the data frames have strings as observations. Sample from df1:

```<code>Name = c("7PR SRO.","7PR","3XL INC","ACME INC","ACME INCORP")
abbr = c("7PR","7PR","3XL","ACME","ACME")
df1<- data.frame(Name, abbr, stringAsFactors=FALSE)
</code>```

The second data frame df2 has same name column as df 1. It only had the name column but to match row entries, i merged them with df1 using the merge function. But i still ended up with around 100+ rows with NA in abbr column. Example:

df2<- data.frame(Name = c("7PR S.R.O.", "3XL LLC", "ACME Ltd"), stringAsFactors=FALSE)

df2's name column also has similar company names like df1 but there could be changes in punctuation or changes from "Corp" to "Ltd" etc. Basically I want 3XL as abbr regardless of whether its LLC or Ltd after the name. I tried using stringdist function
stringdist(df2$Name,df1$Name,method ='jw')
but it gives an error saying "Longer object length is not a multiple of shorter object length".

What i need to get is df1$Name is matched with df2$Name ignoring punctuation or changes in company type such as corp, inc, ltd, llc etc. Can someone please help me find a way to do this?

答:
Creating a new abbr column for future matching/ merging in df2 seems to be ok for you, so this is what I would do:

create a new column df2$abbr in df2 with company names without punctuation

using df1$Name as a lookup to extract the abbreviations of company names

```<code># adding a multiple-word company name
Name = c("7PR SRO.","7PR","3XL INC","ACME INC","ACME INCORP", "ABC Industrial complex LTD")
abbr = c("7PR","7PR","3XL","ACME","ACME", "ABC Industrial complex")

# make data frames
df1<- data.frame(Name, abbr, stringsAsFactors=FALSE)
df2<- data.frame(Name = c("7PR S.R.O.", "3XL LLC", "A.C.M_E Ltd"), stringsAsFactors=FALSE) # added some punctation to ACME

# package needed
library(stringr)

# create new column abbr containing the abbreviations
df2 <- df2 %>%
  mutate(abbr = gsub("[[:punct:]]", "", Name), # get rid of punctuation
         abbr = str_extract(abbr, paste(df1$abbr, collapse = "|"))) # use df1$abbr as lookup
</code>```

Body:
I have two data frames in R with different number of rows. df1 has 2 columns with 12000+ rows and df2 has <200 rows. Both the data frames have strings as observations. Sample from df1:

Name = c("7PR SRO.","7PR","3XL INC","ACME INC","ACME INCORP")
abbr = c("7PR","7PR","3XL","ACME","ACME")
df1<- data.frame(Name, abbr, stringAsFactors=FALSE)

The second data frame df2 has same name column as df 1. It only had the name column but to match row entries, i merged them with df1 using the merge function. But i still ended up with around 100+ rows with NA in abbr column. Example:

df2<- data.frame(Name = c("7PR S.R.O.", "3XL LLC", "ACME Ltd"), stringAsFactors=FALSE)

df2's name column also has similar company names like df1 but there could be changes in punctuation or changes from "Corp" to "Ltd" etc. Basically I want 3XL as abbr regardless of whether its LLC or Ltd after the name. I tried using stringdist function
stringdist(df2$Name,df1$Name,method ='jw')
but it gives an error saying "Longer object length is not a multiple of shorter object length".

What i need to get is df1$Name is matched with df2$Name ignoring punctuation or changes in company type such as corp, inc, ltd, llc etc. Can someone please help me find a way to do this?

Body:
Creating a new abbr column for future matching/ merging in df2 seems to be ok for you, so this is what I would do:

create a new column df2$abbr in df2 with company names without punctuation

using df1$Name as a lookup to extract the abbreviations of company names

# adding a multiple-word company name
Name = c("7PR SRO.","7PR","3XL INC","ACME INC","ACME INCORP", "ABC Industrial complex LTD")
abbr = c("7PR","7PR","3XL","ACME","ACME", "ABC Industrial complex")

# make data frames
df1<- data.frame(Name, abbr, stringsAsFactors=FALSE)
df2<- data.frame(Name = c("7PR S.R.O.", "3XL LLC", "A.C.M_E Ltd"), stringsAsFactors=FALSE) # added some punctation to ACME

# package needed
library(stringr)

# create new column abbr containing the abbreviations
df2 <- df2 %>%
  mutate(abbr = gsub("[[:punct:]]", "", Name), # get rid of punctuation
         abbr = str_extract(abbr, paste(df1$abbr, collapse = "|"))) # use df1$abbr as lookup


问:
How to do a random Monte Carlo scan and getting the outputs in a data file
I have some python program let's say 'Test.py' it has a class and inside this in the init I have to introduce three random variables.

```<code>import math
class Vector():
def __init__(self,vx,vy,vz):
    self.x=vx
    self.y=vy
    self.z=vz

def norm(self):
    xx=self.x**2
    yy=self.y**2
    zz=self.z**2
    return math.sqrt(xx+yy+zz)
</code>```

Now I made a run file 'Testrun.py' which calls this file and then for each dataset it produces one result

```<code>import math
import numpy as np

from Desktop import Test
def random_range(n, min, max):
   return min + np.random.random(n) * (max - min)

model=Test.Vector(x,y,z)

x=random_range(20,2,9)
y=random_range(20,2,9)
z=random_range(20,2,9)

trial_args = np.stack((x, y, z), axis=-1)
for x, y, z in trial_args:
   print(x, y, z, '=>', model.norm())
</code>```

Now I want to store only the results which gives the 'norm'>5 and want to print the inputs and outputs in a data file

答:
Keeping the same 'Test.py'

```<code>import math
class Vector():
 def __init__(self,vx,vy,vz):
    self.x=vx
    self.y=vy
    self.z=vz

 def norm(self):
    xx=self.x**2
    yy=self.y**2
    zz=self.z**2
    return math.sqrt(xx+yy+zz)
</code>```

We have to put the output condition by a if loop

```<code>import math
import numpy as np

from Desktop import Test
def random_range(n, min, max):
return min + np.random.random(n) * (max - min)

x=random_range(20,2,9)
y=random_range(20,2,9)
z=random_range(20,2,9)

trial_args = np.stack((x, y, z), axis=-1)
for x, y, z in trial_args:
    model=Test.Vector(x,y,z)
    if model.norm()>5:
       print(x, y, z, '=>', model.norm())
</code>```

Body:
I have some python program let's say 'Test.py' it has a class and inside this in the init I have to introduce three random variables.

import math
class Vector():
def __init__(self,vx,vy,vz):
    self.x=vx
    self.y=vy
    self.z=vz

def norm(self):
    xx=self.x**2
    yy=self.y**2
    zz=self.z**2
    return math.sqrt(xx+yy+zz)

Now I made a run file 'Testrun.py' which calls this file and then for each dataset it produces one result

import math
import numpy as np

from Desktop import Test
def random_range(n, min, max):
   return min + np.random.random(n) * (max - min)

model=Test.Vector(x,y,z)

x=random_range(20,2,9)
y=random_range(20,2,9)
z=random_range(20,2,9)

trial_args = np.stack((x, y, z), axis=-1)
for x, y, z in trial_args:
   print(x, y, z, '=>', model.norm())

Now I want to store only the results which gives the 'norm'>5 and want to print the inputs and outputs in a data file

Body:
Keeping the same 'Test.py'

import math
class Vector():
 def __init__(self,vx,vy,vz):
    self.x=vx
    self.y=vy
    self.z=vz

 def norm(self):
    xx=self.x**2
    yy=self.y**2
    zz=self.z**2
    return math.sqrt(xx+yy+zz)

We have to put the output condition by a if loop

import math
import numpy as np

from Desktop import Test
def random_range(n, min, max):
return min + np.random.random(n) * (max - min)

x=random_range(20,2,9)
y=random_range(20,2,9)
z=random_range(20,2,9)

trial_args = np.stack((x, y, z), axis=-1)
for x, y, z in trial_args:
    model=Test.Vector(x,y,z)
    if model.norm()>5:
       print(x, y, z, '=>', model.norm())


问:
how can something be bigger than (unsigned long long) > LONG_MAX?
I found this code in an algorithm I need to update:

```<code> if (value > (unsigned long long) LONG_MAX)
</code>```

EDIT: value is the result of a division of two uint64_t numbers.

I understand that (unsigned long long) LONG_MAX is a VERY big number:

```<code>   #include "stdio.h"
   #include "limits.h"

   int main() {
     unsigned long long ull = (unsigned long long) LONG_MAX;
     printf("%lu",ull);
     return 0;
   }
</code>```

prints 9223372036854775807

So what I am comparing here? In what case this if statement will evaluate to true?

答:
LONG_MAX is maximum value for a signed long. By standard it should be >= +2147483647 (fits in 32 bit signed)

There's also ULLONG_MAX for unsigned long long, which is currently most often 18446744073709551615. The standard mandates that to be >= than 9223372036854775807

Body:
I found this code in an algorithm I need to update:

 if (value > (unsigned long long) LONG_MAX)

EDIT: value is the result of a division of two uint64_t numbers.

I understand that (unsigned long long) LONG_MAX is a VERY big number:

   #include "stdio.h"
   #include "limits.h"

   int main() {
     unsigned long long ull = (unsigned long long) LONG_MAX;
     printf("%lu",ull);
     return 0;
   }

prints 9223372036854775807

So what I am comparing here? In what case this if statement will evaluate to true?


问:
how to keep textview below progress of progressbar?
How can i set the position of the x so that it will align correctly below progressbar in all screens?
Below is my activity class.What changes i need to make for the code to work properly?

```<code>public class ProgressBarAvtivity extends AppCompatActivity {
    ProgressBar progressBar;
    TextView tvProgress;
    int d = 60;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar_avtivity);
        progressBar = ( ProgressBar ) findViewById(R.id.progressBar);
        progressBar.setProgress(d);
        tvProgress = ( TextView ) findViewById(R.id.tvProgress);
        tvProgress.setText(String.valueOf(d));
        tvProgress.setX();
    }
}
</code>```

Below is my xml. Please check.

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activity.ProgressBarAvtivity">
    <ProgressBar
        android:id="@+id/progressBar"
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:progressDrawable="@drawable/progreesbar" />
    <TextView
        android:id="@+id/tvProgress"
        android:layout_marginLeft="10dp"
        android:textSize="15sp"
        android:text="35"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout>
</code>```

答:
Try below solution

```<code>private int progressStatus=0;
private Handler handler = new Handler();

Point maxSizePoint = new Point();
getWindowManager().getDefaultDisplay().getSize(maxSizePoint);
final int maxX = maxSizePoint.x;

new Thread(new Runnable() {
    public void run() {
        while (progressStatus < 100) {
            progressStatus += 1;
            // Update the progress bar and display the
            //current value in the text view
            handler.post(new Runnable() {
                public void run() {
                    progressBar.setProgress(progressStatus);
                    int val = (progressStatus * (progressBar.getWidth() - 2 )) / progressBar.getMax();
                    int textViewX = val - (txtView.getWidth() / 2);
                    int finalX = txtView.getWidth() + textViewX > maxX ? (maxX - txtView.getWidth() - 16) : textViewX + 16/*your margin*/;
                    txtView.setX(finalX < 0 ? 16/*your margin*/ : finalX);
                    txtView.setText(String.valueOf(progressStatus));
                }
            });
            try {
                // Sleep for 200 milliseconds.
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}).start();
</code>```

Output

I hope this can help you!

Body:
How can i set the position of the x so that it will align correctly below progressbar in all screens?
Below is my activity class.What changes i need to make for the code to work properly?

public class ProgressBarAvtivity extends AppCompatActivity {
    ProgressBar progressBar;
    TextView tvProgress;
    int d = 60;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar_avtivity);
        progressBar = ( ProgressBar ) findViewById(R.id.progressBar);
        progressBar.setProgress(d);
        tvProgress = ( TextView ) findViewById(R.id.tvProgress);
        tvProgress.setText(String.valueOf(d));
        tvProgress.setX();
    }
}

Below is my xml. Please check.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activity.ProgressBarAvtivity">
    <ProgressBar
        android:id="@+id/progressBar"
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:progressDrawable="@drawable/progreesbar" />
    <TextView
        android:id="@+id/tvProgress"
        android:layout_marginLeft="10dp"
        android:textSize="15sp"
        android:text="35"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout>

Body:
Try below solution

private int progressStatus=0;
private Handler handler = new Handler();

Point maxSizePoint = new Point();
getWindowManager().getDefaultDisplay().getSize(maxSizePoint);
final int maxX = maxSizePoint.x;

new Thread(new Runnable() {
    public void run() {
        while (progressStatus < 100) {
            progressStatus += 1;
            // Update the progress bar and display the
            //current value in the text view
            handler.post(new Runnable() {
                public void run() {
                    progressBar.setProgress(progressStatus);
                    int val = (progressStatus * (progressBar.getWidth() - 2 )) / progressBar.getMax();
                    int textViewX = val - (txtView.getWidth() / 2);
                    int finalX = txtView.getWidth() + textViewX > maxX ? (maxX - txtView.getWidth() - 16) : textViewX + 16/*your margin*/;
                    txtView.setX(finalX < 0 ? 16/*your margin*/ : finalX);
                    txtView.setText(String.valueOf(progressStatus));
                }
            });
            try {
                // Sleep for 200 milliseconds.
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}).start();

Output

I hope this can help you!


问:
A simple "javac" style command-line C/C++ compiler for Windows 7
Over the last couple of months I practiced console programming with Java just with the help of JDK and a text editor of my choice (Notepad++). And I loved the simplicity as a program can be compiled from the command line plainly using javac and run using java.

Now, I'm looking for similar compiler for C/C++, such that I create a .c or .cpp file and compile it in the command prompt, and all it does is create a "native" executable that can be run directly from the command prompt. Thus, without any need of bloated IDE. The reason I'm looking for such simple compiler is because it is going to be used by high-school students so I'm advised to avoid any IDE as far as possible, so students can practice all the concepts of C/C++ languages without having to go for IDE. Which compiler can I use that does this job? also, I must work across all the versions Windows starting from Windows XP.

答:
You can download MinGW which is basically GCC for windows.

Then you can simply gcc somefile.c to create an executable.


问:
How can I return only one record per type?
I have a table with multiple records per one account type and I want to return only one by latest date. I have:

```<code>SELECT
id_nbr AS ID,
contact_type AS contype,
last_update AS date
FROM table
WHERE (contact_type = 'AAA' OR contact_type = 'BBB' OR contact_type = 'CCC');
</code>```

It may return something like this:

```<code>ID          contype     date
111111111   AAA         2020-01-30
111111111   AAA         2019-05-05
111111111   BBB         2020-01-02
111111111   CCC         2020-02-17
</code>```

Looking at this data, I only want 3 rows because contype has multiple AAA records but I only want the latest date. Something like:

```<code>ID          contype     date
111111111   AAA         2020-01-30
111111111   BBB         2020-01-02
111111111   CCC         2020-02-17
</code>```

This is obviously very high-level but how can I achieve this? This would help me tremendously. Thanks in advance!!

答:
Use qualify:

```<code>SELECT id_nbr AS ID, contact_type AS contype, last_update AS date
FROM table
WHERE contact_type IN ('AAA', 'BBB' , 'CCC')
QUALIFY ROW_NUMBER() OVER (PARTITION BY contact_type ORDER BY last_update DESC) = 1;
</code>```

This returns the most recent row for each type.

Body:
I have a table with multiple records per one account type and I want to return only one by latest date. I have:

SELECT
id_nbr AS ID,
contact_type AS contype,
last_update AS date
FROM table
WHERE (contact_type = 'AAA' OR contact_type = 'BBB' OR contact_type = 'CCC');

It may return something like this:

ID          contype     date
111111111   AAA         2020-01-30
111111111   AAA         2019-05-05
111111111   BBB         2020-01-02
111111111   CCC         2020-02-17

Looking at this data, I only want 3 rows because contype has multiple AAA records but I only want the latest date. Something like:

ID          contype     date
111111111   AAA         2020-01-30
111111111   BBB         2020-01-02
111111111   CCC         2020-02-17

This is obviously very high-level but how can I achieve this? This would help me tremendously. Thanks in advance!!

Body:
Use qualify:

SELECT id_nbr AS ID, contact_type AS contype, last_update AS date
FROM table
WHERE contact_type IN ('AAA', 'BBB' , 'CCC')
QUALIFY ROW_NUMBER() OVER (PARTITION BY contact_type ORDER BY last_update DESC) = 1;

This returns the most recent row for each type.


问:
elastic - QueryingParsingException - query does not support - when searching by association field using a filter
I have a model person that has many addresses (association/table name person_addresses)
I am trying to give the user the ability to find a person by its address.

When I try to search by address, I get: QueryingParsingException - query does not support [addresses.address]

e.g: /api/v1/search/people?q=aaron&address=scarborough

query:

```<code>[
   {
      "query":{
         "match":{
            "name":"aaron"
         }
      },
      "sort":[
         {
            "id":{
               "order":"desc"
            }
         }
      ],
      "filter":{
         "bool":{
            "must":{
               "nested":{
                  "path":"addresses",
                  "query":{
                     "terms":{
                        "addresses.address":"scarborough"
                     }
                  }
               }
            }
         }
      },
      "aggregations":{
         "addresses":{
            "nested":{
               "path":"addresses"
            },
            "aggregations":{
               "nested_items":{
                  "terms":{
                     "field":"addresses.address",
                     "order":{
                        "_count":"desc"
                     }
                  }
               }
            }
         }
      }
   }
]
</code>```

mapping:

```<code>  mapping do
    indexes :first_name, type: 'multi_field', fields: {
      first_name: { type: 'string', index: 'analyzed' },
      na_first_name: { type: 'string', index: 'not_analyzed' }
    }
    indexes :middle_name, type: 'multi_field', fields: {
      middle_name: { type: 'string', index: 'analyzed' },
      na_middle_name: { type: 'string', index: 'not_analyzed' }
    }
    indexes :last_name, type: 'multi_field', fields: {
      last_name: { type: 'string', index: 'analyzed' },
      na_last_name: { type: 'string', index: 'not_analyzed' }
    }
    indexes :addresses, type: :nested do
      indexes :location, type: :geo_point, index: :not_analyzed
      indexes :country, type: :string, index: :not_analyzed
      indexes :state, type: :string, index: :not_analyzed
      indexes :address, type: :string
      indexes :county, type: :string, index: :not_analyzed
      indexes :city, type: :string, index: :not_analyzed
      indexes :zip, type: :string, index: :not_analyzed
      indexes :state_id, type: :long
      indexes :county_id, type: :long
      indexes :city_id, type: :long
    end
  end
</code>```

I have this record indexed:

```<code> {
        "_index": "pl_people",
        "_type": "person",
        "_id": "813106",
        "_score": null,
        "sort": [
            -9223372036854775808
        ],
        "resource": "Person",
        "parameterized": "813106-aaron-mcguire",
        "name": "Aaron McGuire",
        "phone": "813-689-6889",
        "date_of_birth": "1991-03-01",
        "first_name": "Aaron",
        "last_name": "McGuire",
        "addresses": [
            {
                "id": 1,
                "parameterized": "1",
                "address": "123 Scarborough road",
                "zip": "L5A2A9",
                "city": "Ontario",
                "country": "USA",
                "state": "California",
                "location": null,
                "state_id": null,
                "county_id": null,
                "city_id": null
            }
        ],
        "projects": [],
    }
</code>```

index.json.jbuilder:

```<code># frozen_string_literal: true

json.query do
  if @term.present?
    json.set!(:match, @field => @term)
  else
    json.set!(:match_all, {})
  end
end

json.sort do
  json.child! do
    json.set!(:id, order: 'desc')
  end
end

if [@address].any?(&:present?)
  json.filter do
    json.partial!('people/index/filters')
  end
end

json.aggregations do
  json.addresses do
    json.nested do
      json.set!(:path, 'addresses')
    end
    json.aggregations do
      json.nested_items do
        json.terms do
          json.set!(:field, 'addresses.address')
          json.set!(:order, _count: 'desc')
        end
      end
    end
  end
end
</code>```

_filters.json.jbuilder:

```<code># frozen_string_literal: true

json.bool do
  json.must do
    if (value = @address).present?
      json.nested do
        json.path('addresses')
        json.query do
          json.set!(:terms, 'addresses.address' => value)
        end
      end
    end
  end
end
</code>```

index.rb (person search)

```<code># frozen_string_literal: true

module Searching
  module People
    class Index < ::Searching::ApplicationSearching
      self.valid_params = {
        q: { type: :string, on_blank: :remove },
      }

      delegate :aggregations, to: :results

      def initialize(params = {})
        super(params)
      end

      protected

      def klass
        Person
      end

      def search
        @search ||= ClientSearch.new(
          index: [klass].map(&:index_name).join(','),
          body: body,
          size: limit,
          from: offset,
        )
      end

      def body
        query_field = params[:field].present? ? params[:field] : :name
        Searching::TemplateHandler.(
          'people/index',
          term: Searching::Util.sanitize_string(params[:q]),
          field: query_field,
          address: params[:address],
        )
      end

    end
  end
end
</code>```

GET /pl_people

```<code>{
   "pl_people":{
      "aliases":{

      },
      "mappings":{
         "person":{
            "properties":{
               "ac_name":{
                  "type":"string",
                  "analyzer":"autocomplete"
               },
               "addresses":{
                  "type":"nested",
                  "properties":{
                     "address":{
                        "type":"string"
                     },
                     "city":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "city_id":{
                        "type":"long"
                     },
                     "country":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county_id":{
                        "type":"long"
                     },
                     "id":{
                        "type":"long"
                     },
                     "location":{
                        "type":"geo_point"
                     },
                     "parameterized":{
                        "type":"string"
                     },
                     "state":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "state_id":{
                        "type":"long"
                     },
                     "zip":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "author":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "body":{
                  "type":"string",
                  "analyzer":"remove_html",
                  "fields":{
                     "ns_body":{
                        "type":"string",
                        "analyzer":"remove_html_stopwords"
                     }
                  }
               },
               "charities":{
                  "type":"nested",
                  "properties":{
                     "email":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "id":{
                        "type":"long"
                     }
                  }
               },
               "community":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "created_at":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "date_of_birth":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "description":{
                  "type":"string"
               },
               "employments":{
                  "type":"nested",
                  "properties":{
                     "email":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "employment_status":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "foia_contact":{
                        "type":"boolean"
                     },
                     "id":{
                        "type":"long"
                     },
                     "phone":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "phone_extension":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "first_name":{
                  "type":"string",
                  "fields":{
                     "na_first_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "last_name":{
                  "type":"string",
                  "fields":{
                     "na_last_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "market":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "middle_name":{
                  "type":"string",
                  "fields":{
                     "na_middle_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "most_recent_organization":{
                  "properties":{
                     "description":{
                        "type":"string"
                     },
                     "id":{
                        "type":"long"
                     },
                     "name":{
                        "type":"string"
                     },
                     "parameterized":{
                        "type":"string"
                     },
                     "phone":{
                        "type":"string"
                     }
                  }
               },
               "name":{
                  "type":"string",
                  "fields":{
                     "na_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "ngram_name":{
                        "type":"string",
                        "analyzer":"my_start"
                     },
                     "ns_name":{
                        "type":"string",
                        "analyzer":"no_stopwords"
                     }
                  }
               },
               "organizations":{
                  "properties":{
                     "name":{
                        "type":"string"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "package":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "parameterized":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "phone":{
                  "type":"string"
               },
               "photo":{
                  "properties":{
                     "large":{
                        "type":"string"
                     },
                     "medium":{
                        "type":"string"
                     },
                     "teaser":{
                        "type":"string"
                     },
                     "thumb":{
                        "type":"string"
                     },
                     "url":{
                        "type":"string"
                     }
                  }
               },
               "projects":{
                  "properties":{
                     "id":{
                        "type":"long"
                     },
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "public_offices":{
                  "type":"nested",
                  "properties":{
                     "email":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "employment_status":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "id":{
                        "type":"long"
                     }
                  }
               },
               "published":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "region":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "resource":{
                  "type":"string"
               },
               "short_description":{
                  "type":"string"
               },
               "show_path":{
                  "type":"string"
               },
               "time":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "updated_at":{
                  "type":"date",
                  "format":"dateOptionalTime"
               }
            }
         }
      },
      "settings":{
         "index":{
            "creation_date":"1581684793139",
            "analysis":{
               "filter":{
                  "english_stop":{
                     "type":"stop",
                     "stopwords":[
                        "a",
                        "an",
                        "and",
                        "are",
                        "as",
                        "at",
                        "be",
                        "but",
                        "by",
                        "for",
                        "if",
                        "in",
                        "into",
                        "is",
                        "it",
                        "no",
                        "not",
                        "of",
                        "on",
                        "or",
                        "such",
                        "that",
                        "the",
                        "their",
                        "then",
                        "there",
                        "these",
                        "they",
                        "this",
                        "to",
                        "was",
                        "with"
                     ]
                  },
                  "my_edge":{
                     "min_gram":"2",
                     "side":"front",
                     "type":"edgeNGram",
                     "max_gram":"18"
                  }
               },
               "analyzer":{
                  "no_stopwords":{
                     "type":"stop",
                     "stopwords":"_english_"
                  },
                  "comma":{
                     "pattern":",",
                     "type":"pattern"
                  },
                  "default":{
                     "filter":[
                        "standard",
                        "lowercase",
                        "english_stop",
                        "word_delimiter"
                     ],
                     "tokenizer":"standard"
                  },
                  "remove_html_stopwords":{
                     "filter":"stop",
                     "char_filter":"html_strip",
                     "type":"custom",
                     "stopwords":"_english_",
                     "tokenizer":"lowercase"
                  },
                  "autocomplete":{
                     "filter":[
                        "lowercase",
                        "apostrophe"
                     ],
                     "tokenizer":"keyword"
                  },
                  "my_start":{
                     "filter":[
                        "asciifolding",
                        "lowercase",
                        "my_edge"
                     ],
                     "tokenizer":"whitespace"
                  },
                  "remove_html":{
                     "filter":"lowercase",
                     "char_filter":"html_strip",
                     "type":"custom",
                     "tokenizer":"standard"
                  }
               }
            },
            "number_of_shards":"5",
            "number_of_replicas":"1",
            "version":{
               "created":"1070699"
            },
            "uuid":"LZrnPjxiTwyNf-Ggo3bXtw"
         }
      },
      "warmers":{

      }
   }
}
</code>```

Any naming conventions I am not following?
I tried changing person_address for address on filters.json and index.json, but still didnt have any success.

答:
So i reinstall es 1.7 and made some try, simplified your data.

the error was in the "terms" in the filter, you have to use a term / match instead. If you want to add multiple condition it seems you need to build boolean query with a term on each.

Moreover i cant understand why you use a post_filter here (filter at top level = post_filter in es > 2.X), can you explain it?

This is what i done using HEAD if you want reproduce (i simplify the mappings, keeping only relevant fields).

hope it s help.

http://localhost:9200/pl_people/ (POST)

```<code>{
      "mappings":{
         "person":{
            "properties":{
               "ac_name":{
                  "type":"string"
               },
               "addresses":{
                  "type":"nested",
                  "properties":{
                     "address":{
                        "type":"string"
                     },
                     "city":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "city_id":{
                        "type":"long"
                     },
                     "country":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county_id":{
                        "type":"long"
                     },
                     "id":{
                        "type":"long"
                     },
                     "location":{
                        "type":"geo_point"
                     },
                     "parameterized":{
                        "type":"string"
                     },
                     "state":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "state_id":{
                        "type":"long"
                     },
                     "zip":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "date_of_birth":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "first_name":{
                  "type":"string",
                  "fields":{
                     "na_first_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "last_name":{
                  "type":"string",
                  "fields":{
                     "na_last_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "name":{
                  "type":"string",
                  "fields":{
                     "na_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "ngram_name":{
                        "type":"string"
                     },
                     "ns_name":{
                        "type":"string"
                     }
                  }
               },
               "parameterized":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "phone":{
                  "type":"string"
               },
               "resource":{
                  "type":"string"
               }
            }
         }
      }
}
</code>```

http://localhost:9200/pl_people/person/813106 (POST)

```<code>{
        "ac_name": "Aaron McGuire",
        "resource": "Person",
        "parameterized": "813106-aaron-mcguire",
        "name": "Aaron McGuire",
        "phone": "813-689-6889",
        "date_of_birth": "1991-03-01",
        "first_name": "Aaron",
        "last_name": "McGuire",
        "addresses": [
            {
                "id": 1,
                "parameterized": "1",
                "address": "123 Scarborough road",
                "zip": "L5A2A9",
                "city": "Ontario",
                "country": "USA",
                "state": "California"
            }
        ]
    }
</code>```

http://localhost:9200/pl_people/person/_search/ (post)

```<code>{
  "query": {
    "match": {
      "name": "aaron"
    }
  },
  "sort": [
    {
      "id": {
        "order": "desc"
      }
    }
  ],
  "filter": {
    "bool": {
      "must": {
        "nested": {
          "path": "addresses",
          "query": {
            "term": {
              "addresses.address": "scarborough"
            }
          }
        }
      }
    }
  },
  "aggregations": {
    "addresses": {
      "nested": {
        "path": "addresses"
      },
      "aggregations": {
        "nested_items": {
          "terms": {
            "field": "addresses.address",
            "order": {
              "_count": "desc"
            }
          }
        }
      }
    }
  }
}
</code>```

Body:
I have a model person that has many addresses (association/table name person_addresses)
I am trying to give the user the ability to find a person by its address.

When I try to search by address, I get: QueryingParsingException - query does not support [addresses.address]

e.g: /api/v1/search/people?q=aaron&address=scarborough

query:

[
   {
      "query":{
         "match":{
            "name":"aaron"
         }
      },
      "sort":[
         {
            "id":{
               "order":"desc"
            }
         }
      ],
      "filter":{
         "bool":{
            "must":{
               "nested":{
                  "path":"addresses",
                  "query":{
                     "terms":{
                        "addresses.address":"scarborough"
                     }
                  }
               }
            }
         }
      },
      "aggregations":{
         "addresses":{
            "nested":{
               "path":"addresses"
            },
            "aggregations":{
               "nested_items":{
                  "terms":{
                     "field":"addresses.address",
                     "order":{
                        "_count":"desc"
                     }
                  }
               }
            }
         }
      }
   }
]

mapping:

  mapping do
    indexes :first_name, type: 'multi_field', fields: {
      first_name: { type: 'string', index: 'analyzed' },
      na_first_name: { type: 'string', index: 'not_analyzed' }
    }
    indexes :middle_name, type: 'multi_field', fields: {
      middle_name: { type: 'string', index: 'analyzed' },
      na_middle_name: { type: 'string', index: 'not_analyzed' }
    }
    indexes :last_name, type: 'multi_field', fields: {
      last_name: { type: 'string', index: 'analyzed' },
      na_last_name: { type: 'string', index: 'not_analyzed' }
    }
    indexes :addresses, type: :nested do
      indexes :location, type: :geo_point, index: :not_analyzed
      indexes :country, type: :string, index: :not_analyzed
      indexes :state, type: :string, index: :not_analyzed
      indexes :address, type: :string
      indexes :county, type: :string, index: :not_analyzed
      indexes :city, type: :string, index: :not_analyzed
      indexes :zip, type: :string, index: :not_analyzed
      indexes :state_id, type: :long
      indexes :county_id, type: :long
      indexes :city_id, type: :long
    end
  end

I have this record indexed:

 {
        "_index": "pl_people",
        "_type": "person",
        "_id": "813106",
        "_score": null,
        "sort": [
            -9223372036854775808
        ],
        "resource": "Person",
        "parameterized": "813106-aaron-mcguire",
        "name": "Aaron McGuire",
        "phone": "813-689-6889",
        "date_of_birth": "1991-03-01",
        "first_name": "Aaron",
        "last_name": "McGuire",
        "addresses": [
            {
                "id": 1,
                "parameterized": "1",
                "address": "123 Scarborough road",
                "zip": "L5A2A9",
                "city": "Ontario",
                "country": "USA",
                "state": "California",
                "location": null,
                "state_id": null,
                "county_id": null,
                "city_id": null
            }
        ],
        "projects": [],
    }

index.json.jbuilder:

# frozen_string_literal: true

json.query do
  if @term.present?
    json.set!(:match, @field => @term)
  else
    json.set!(:match_all, {})
  end
end

json.sort do
  json.child! do
    json.set!(:id, order: 'desc')
  end
end

if [@address].any?(&:present?)
  json.filter do
    json.partial!('people/index/filters')
  end
end

json.aggregations do
  json.addresses do
    json.nested do
      json.set!(:path, 'addresses')
    end
    json.aggregations do
      json.nested_items do
        json.terms do
          json.set!(:field, 'addresses.address')
          json.set!(:order, _count: 'desc')
        end
      end
    end
  end
end

_filters.json.jbuilder:

# frozen_string_literal: true

json.bool do
  json.must do
    if (value = @address).present?
      json.nested do
        json.path('addresses')
        json.query do
          json.set!(:terms, 'addresses.address' => value)
        end
      end
    end
  end
end

index.rb (person search)

# frozen_string_literal: true

module Searching
  module People
    class Index < ::Searching::ApplicationSearching
      self.valid_params = {
        q: { type: :string, on_blank: :remove },
      }

      delegate :aggregations, to: :results

      def initialize(params = {})
        super(params)
      end

      protected

      def klass
        Person
      end

      def search
        @search ||= ClientSearch.new(
          index: [klass].map(&:index_name).join(','),
          body: body,
          size: limit,
          from: offset,
        )
      end

      def body
        query_field = params[:field].present? ? params[:field] : :name
        Searching::TemplateHandler.(
          'people/index',
          term: Searching::Util.sanitize_string(params[:q]),
          field: query_field,
          address: params[:address],
        )
      end

    end
  end
end

GET /pl_people

{
   "pl_people":{
      "aliases":{

      },
      "mappings":{
         "person":{
            "properties":{
               "ac_name":{
                  "type":"string",
                  "analyzer":"autocomplete"
               },
               "addresses":{
                  "type":"nested",
                  "properties":{
                     "address":{
                        "type":"string"
                     },
                     "city":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "city_id":{
                        "type":"long"
                     },
                     "country":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county_id":{
                        "type":"long"
                     },
                     "id":{
                        "type":"long"
                     },
                     "location":{
                        "type":"geo_point"
                     },
                     "parameterized":{
                        "type":"string"
                     },
                     "state":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "state_id":{
                        "type":"long"
                     },
                     "zip":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "author":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "body":{
                  "type":"string",
                  "analyzer":"remove_html",
                  "fields":{
                     "ns_body":{
                        "type":"string",
                        "analyzer":"remove_html_stopwords"
                     }
                  }
               },
               "charities":{
                  "type":"nested",
                  "properties":{
                     "email":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "id":{
                        "type":"long"
                     }
                  }
               },
               "community":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "created_at":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "date_of_birth":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "description":{
                  "type":"string"
               },
               "employments":{
                  "type":"nested",
                  "properties":{
                     "email":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "employment_status":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "foia_contact":{
                        "type":"boolean"
                     },
                     "id":{
                        "type":"long"
                     },
                     "phone":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "phone_extension":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "first_name":{
                  "type":"string",
                  "fields":{
                     "na_first_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "last_name":{
                  "type":"string",
                  "fields":{
                     "na_last_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "market":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "middle_name":{
                  "type":"string",
                  "fields":{
                     "na_middle_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "most_recent_organization":{
                  "properties":{
                     "description":{
                        "type":"string"
                     },
                     "id":{
                        "type":"long"
                     },
                     "name":{
                        "type":"string"
                     },
                     "parameterized":{
                        "type":"string"
                     },
                     "phone":{
                        "type":"string"
                     }
                  }
               },
               "name":{
                  "type":"string",
                  "fields":{
                     "na_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "ngram_name":{
                        "type":"string",
                        "analyzer":"my_start"
                     },
                     "ns_name":{
                        "type":"string",
                        "analyzer":"no_stopwords"
                     }
                  }
               },
               "organizations":{
                  "properties":{
                     "name":{
                        "type":"string"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "package":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "parameterized":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "phone":{
                  "type":"string"
               },
               "photo":{
                  "properties":{
                     "large":{
                        "type":"string"
                     },
                     "medium":{
                        "type":"string"
                     },
                     "teaser":{
                        "type":"string"
                     },
                     "thumb":{
                        "type":"string"
                     },
                     "url":{
                        "type":"string"
                     }
                  }
               },
               "projects":{
                  "properties":{
                     "id":{
                        "type":"long"
                     },
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "public_offices":{
                  "type":"nested",
                  "properties":{
                     "email":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "employment_status":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "id":{
                        "type":"long"
                     }
                  }
               },
               "published":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "region":{
                  "properties":{
                     "name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "parameterized":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "slug":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "resource":{
                  "type":"string"
               },
               "short_description":{
                  "type":"string"
               },
               "show_path":{
                  "type":"string"
               },
               "time":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "updated_at":{
                  "type":"date",
                  "format":"dateOptionalTime"
               }
            }
         }
      },
      "settings":{
         "index":{
            "creation_date":"1581684793139",
            "analysis":{
               "filter":{
                  "english_stop":{
                     "type":"stop",
                     "stopwords":[
                        "a",
                        "an",
                        "and",
                        "are",
                        "as",
                        "at",
                        "be",
                        "but",
                        "by",
                        "for",
                        "if",
                        "in",
                        "into",
                        "is",
                        "it",
                        "no",
                        "not",
                        "of",
                        "on",
                        "or",
                        "such",
                        "that",
                        "the",
                        "their",
                        "then",
                        "there",
                        "these",
                        "they",
                        "this",
                        "to",
                        "was",
                        "with"
                     ]
                  },
                  "my_edge":{
                     "min_gram":"2",
                     "side":"front",
                     "type":"edgeNGram",
                     "max_gram":"18"
                  }
               },
               "analyzer":{
                  "no_stopwords":{
                     "type":"stop",
                     "stopwords":"_english_"
                  },
                  "comma":{
                     "pattern":",",
                     "type":"pattern"
                  },
                  "default":{
                     "filter":[
                        "standard",
                        "lowercase",
                        "english_stop",
                        "word_delimiter"
                     ],
                     "tokenizer":"standard"
                  },
                  "remove_html_stopwords":{
                     "filter":"stop",
                     "char_filter":"html_strip",
                     "type":"custom",
                     "stopwords":"_english_",
                     "tokenizer":"lowercase"
                  },
                  "autocomplete":{
                     "filter":[
                        "lowercase",
                        "apostrophe"
                     ],
                     "tokenizer":"keyword"
                  },
                  "my_start":{
                     "filter":[
                        "asciifolding",
                        "lowercase",
                        "my_edge"
                     ],
                     "tokenizer":"whitespace"
                  },
                  "remove_html":{
                     "filter":"lowercase",
                     "char_filter":"html_strip",
                     "type":"custom",
                     "tokenizer":"standard"
                  }
               }
            },
            "number_of_shards":"5",
            "number_of_replicas":"1",
            "version":{
               "created":"1070699"
            },
            "uuid":"LZrnPjxiTwyNf-Ggo3bXtw"
         }
      },
      "warmers":{

      }
   }
}

Any naming conventions I am not following?
I tried changing person_address for address on filters.json and index.json, but still didnt have any success.

Body:
So i reinstall es 1.7 and made some try, simplified your data.

the error was in the "terms" in the filter, you have to use a term / match instead. If you want to add multiple condition it seems you need to build boolean query with a term on each.

Moreover i cant understand why you use a post_filter here (filter at top level = post_filter in es > 2.X), can you explain it?

This is what i done using HEAD if you want reproduce (i simplify the mappings, keeping only relevant fields).

hope it s help.

http://localhost:9200/pl_people/ (POST)

{
      "mappings":{
         "person":{
            "properties":{
               "ac_name":{
                  "type":"string"
               },
               "addresses":{
                  "type":"nested",
                  "properties":{
                     "address":{
                        "type":"string"
                     },
                     "city":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "city_id":{
                        "type":"long"
                     },
                     "country":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "county_id":{
                        "type":"long"
                     },
                     "id":{
                        "type":"long"
                     },
                     "location":{
                        "type":"geo_point"
                     },
                     "parameterized":{
                        "type":"string"
                     },
                     "state":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "state_id":{
                        "type":"long"
                     },
                     "zip":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "date_of_birth":{
                  "type":"date",
                  "format":"dateOptionalTime"
               },
               "first_name":{
                  "type":"string",
                  "fields":{
                     "na_first_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "last_name":{
                  "type":"string",
                  "fields":{
                     "na_last_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "name":{
                  "type":"string",
                  "fields":{
                     "na_name":{
                        "type":"string",
                        "index":"not_analyzed"
                     },
                     "ngram_name":{
                        "type":"string"
                     },
                     "ns_name":{
                        "type":"string"
                     }
                  }
               },
               "parameterized":{
                  "type":"string",
                  "index":"not_analyzed"
               },
               "phone":{
                  "type":"string"
               },
               "resource":{
                  "type":"string"
               }
            }
         }
      }
}

http://localhost:9200/pl_people/person/813106 (POST)

{
        "ac_name": "Aaron McGuire",
        "resource": "Person",
        "parameterized": "813106-aaron-mcguire",
        "name": "Aaron McGuire",
        "phone": "813-689-6889",
        "date_of_birth": "1991-03-01",
        "first_name": "Aaron",
        "last_name": "McGuire",
        "addresses": [
            {
                "id": 1,
                "parameterized": "1",
                "address": "123 Scarborough road",
                "zip": "L5A2A9",
                "city": "Ontario",
                "country": "USA",
                "state": "California"
            }
        ]
    }

http://localhost:9200/pl_people/person/_search/ (post)

{
  "query": {
    "match": {
      "name": "aaron"
    }
  },
  "sort": [
    {
      "id": {
        "order": "desc"
      }
    }
  ],
  "filter": {
    "bool": {
      "must": {
        "nested": {
          "path": "addresses",
          "query": {
            "term": {
              "addresses.address": "scarborough"
            }
          }
        }
      }
    }
  },
  "aggregations": {
    "addresses": {
      "nested": {
        "path": "addresses"
      },
      "aggregations": {
        "nested_items": {
          "terms": {
            "field": "addresses.address",
            "order": {
              "_count": "desc"
            }
          }
        }
      }
    }
  }
}