Skip to content

instant-meilisearch: _matchesPosition does not appear in adapted hits #1305

@mavcook

Description

@mavcook

Description

When using showMatchesPosition=true, the _matchesPosition field does not appear in the instantsearch hits.

I believe I narrowed this down and is due to the _matchesPosition not being assigned to the adapted hit here.

Reproducing

  1. Setup: Modify the vanillajs playground to use showMatchesPosition:
const search = instantsearch({
  indexName: 'steam-video-games',
  searchClient: instantMeiliSearch(
    'https://ms-adf78ae33284-106.lon.meilisearch.io',
    'a63da4928426f12639e19d62886f621130f3fa9ff3c7534c5d179f0f51c4f303',
    {
      finitePagination: true,
      meiliSearchParams: {showMatchesPosition: true},
    }
  ).searchClient,
})

...
// add transformItems so we can log for debugging
  instantsearch.widgets.hits({
    container: '#hits',
    transformItems(items) {
      console.log('Here are the results', items)
      return items
    },
...
  1. Search 'half' in the playground

Expected behavior

Searching 'half' in the vanillajs playground should give this as the first hit

Note the _matchesPosition field in the json below

Expected first result
{
  "name": [
      {
          "start": 0,
          "length": 4
      }
  ],
  "description": "Return to the Black Mesa Research Facility as one of the military specialists assigned to eliminate Gordon Freeman. Experience an entirely new episode of single player action. Meet fierce alien opponents and experiment with new weaponry. Named Game of the Year by the Academy of Interactive Arts and Sciences.",
  "id": "50",
  "price": "4.99 $",
  "image": "http://steam.meilisearch.dev/steam/apps/50/header.jpg?t=1447350813",
  "releaseDate": "Nov 1 1999",
  "recommendationCount": 2934,
  "platforms": [
      "MacOS",
      "Linux",
      "Windows"
  ],
  "players": [
      "Single player",
      "Multiplayer"
  ],
  "genres": [
      "Action"
  ],
  "misc": [],
  "_highlightResult": {
      "name": {
          "value": "<mark>Half</mark>-Life: Opposing Force"
      },
      "description": {
          "value": "Return to the Black Mesa Research Facility as one of the military specialists assigned to eliminate Gordon Freeman. Experience an entirely new episode of single player action. Meet fierce alien opponents and experiment with new weaponry. Named Game of the Year by the Academy of Interactive Arts and Sciences."
      },
      "id": {
          "value": "50"
      },
      "price": {
          "value": "4.99 $"
      },
      "image": {
          "value": "http://steam.meilisearch.dev/steam/apps/50/header.jpg?t=1447350813"
      },
      "releaseDate": {
          "value": "Nov 1 1999"
      },
      "recommendationCount": {
          "value": "2934"
      },
      "platforms": [
          {
              "value": "MacOS"
          },
          {
              "value": "Linux"
          },
          {
              "value": "Windows"
          }
      ],
      "players": [
          {
              "value": "Single player"
          },
          {
              "value": "Multiplayer"
          }
      ],
      "genres": [
          {
              "value": "Action"
          }
      ],
      "misc": []
  },
  "_snippetResult": {
      "name": {
          "value": "<mark>Half</mark>-Life: Opposing Force"
      },
      "description": {
          "value": "Return to the Black Mesa Research Facility as one of the military specialists assigned to eliminate Gordon Freeman. Experience an entirely new episode of single player action. Meet fierce alien opponents and experiment with new weaponry. Named Game of the Year by the Academy of Interactive Arts and Sciences."
      },
      "id": {
          "value": "50"
      },
      "price": {
          "value": "4.99 $"
      },
      "image": {
          "value": "http://steam.meilisearch.dev/steam/apps/50/header.jpg?t=1447350813"
      },
      "releaseDate": {
          "value": "Nov 1 1999"
      },
      "recommendationCount": {
          "value": "2934"
      },
      "platforms": [
          {
              "value": "MacOS"
          },
          {
              "value": "Linux"
          },
          {
              "value": "Windows"
          }
      ],
      "players": [
          {
              "value": "Single player"
          },
          {
              "value": "Multiplayer"
          }
      ],
      "genres": [
          {
              "value": "Action"
          }
      ],
      "misc": []
  },
  "_matchesPosition": {
      "name": [
          {
              "start": 0,
              "length": 4
          }
      ]
  },
  "__position": 1
}

Current behavior

No _matchesPosition field in first result for 'half' query

Current first result
{
  "name": [
      {
          "start": 0,
          "length": 4
      }
  ],
  "description": "Return to the Black Mesa Research Facility as one of the military specialists assigned to eliminate Gordon Freeman. Experience an entirely new episode of single player action. Meet fierce alien opponents and experiment with new weaponry. Named Game of the Year by the Academy of Interactive Arts and Sciences.",
  "id": "50",
  "price": "4.99 $",
  "image": "http://steam.meilisearch.dev/steam/apps/50/header.jpg?t=1447350813",
  "releaseDate": "Nov 1 1999",
  "recommendationCount": 2934,
  "platforms": [
      "MacOS",
      "Linux",
      "Windows"
  ],
  "players": [
      "Single player",
      "Multiplayer"
  ],
  "genres": [
      "Action"
  ],
  "misc": [],
  "_highlightResult": {
      "name": {
          "value": "<mark>Half</mark>-Life: Opposing Force"
      },
      "description": {
          "value": "Return to the Black Mesa Research Facility as one of the military specialists assigned to eliminate Gordon Freeman. Experience an entirely new episode of single player action. Meet fierce alien opponents and experiment with new weaponry. Named Game of the Year by the Academy of Interactive Arts and Sciences."
      },
      "id": {
          "value": "50"
      },
      "price": {
          "value": "4.99 $"
      },
      "image": {
          "value": "http://steam.meilisearch.dev/steam/apps/50/header.jpg?t=1447350813"
      },
      "releaseDate": {
          "value": "Nov 1 1999"
      },
      "recommendationCount": {
          "value": "2934"
      },
      "platforms": [
          {
              "value": "MacOS"
          },
          {
              "value": "Linux"
          },
          {
              "value": "Windows"
          }
      ],
      "players": [
          {
              "value": "Single player"
          },
          {
              "value": "Multiplayer"
          }
      ],
      "genres": [
          {
              "value": "Action"
          }
      ],
      "misc": []
  },
  "_snippetResult": {
      "name": {
          "value": "<mark>Half</mark>-Life: Opposing Force"
      },
      "description": {
          "value": "Return to the Black Mesa Research Facility as one of the military specialists assigned to eliminate Gordon Freeman. Experience an entirely new episode of single player action. Meet fierce alien opponents and experiment with new weaponry. Named Game of the Year by the Academy of Interactive Arts and Sciences."
      },
      "id": {
          "value": "50"
      },
      "price": {
          "value": "4.99 $"
      },
      "image": {
          "value": "http://steam.meilisearch.dev/steam/apps/50/header.jpg?t=1447350813"
      },
      "releaseDate": {
          "value": "Nov 1 1999"
      },
      "recommendationCount": {
          "value": "2934"
      },
      "platforms": [
          {
              "value": "MacOS"
          },
          {
              "value": "Linux"
          },
          {
              "value": "Windows"
          }
      ],
      "players": [
          {
              "value": "Single player"
          },
          {
              "value": "Multiplayer"
          }
      ],
      "genres": [
          {
              "value": "Action"
          }
      ],
      "misc": []
  },
  "__position": 1
}

Environment:

  • Meilisearch version: 1.8.3
  • instant-meilisearch version: 0.19.0
  • instantsearch.js version: 4.72.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions