Select to view content in your preferred language

Search Component exactMatch possible BUG?

424
5
Jump to solution
02-20-2026 01:00 PM
MatthewDriscoll
MVP Alum

The search component in 4.34 does not seem to honor exactMatch:False.  It will only honor it if the search is in the first characters.  Say I am looking for "Driscoll" if I search 'ris' it will not come up, but if I do 'Dri' it will.  

In 4.34 the exactMatch: false → prefix only.  Where in 4.21 it's like: LIKE '%ris%'

// Wait for your view to be ready
const quickSearch = document.getElementById("quickSearch");
await quickSearch.componentOnReady();

// Assign the map view
quickSearch.view = view;

// Configure only your parcel layer sources
quickSearch.sources = [
  {
    layer: parcelLayer,
    searchFields: ["PartyName_1"],
    name: "Search by Owner",
    exactMatch: false,
    outFields: ["PartyName_1"],
    displayField: "PartyName_1",
    suggestionsEnabled: true,
  },
  {
    layer: parcelLayer,
    searchFields: ["PropertyAddress"],
    name: "Search by Address",
    outFields: ["PropertyAddress"],
    displayField: "PropertyAddress",
    exactMatch: false,
  },
  {
    layer: parcelLayer,
    searchFields: ["QuickRefID_1"],
    name: "Search by Quick Reference ID",
    outFields: ["QuickRefID_1"],
    displayField: "QuickRefID_1",
    exactMatch: false,
  }
];

 

0 Kudos
2 Solutions

Accepted Solutions
WesleyO
Esri Contributor

@MatthewDriscoll This is the expected behavior. The change was introduced in 4.25: https://developers.arcgis.com/javascript/latest/4.25/#search-performance-improvements

 

This AGOL blog also gives additional insights into why this change may have occurred: https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/searching-for-features-in-maps-and-a...

View solution in original post

MatthewDriscoll
MVP Alum

Idea thread found here.

Solution:

// Configure only your parcel layer sources
// Custom getSuggestions bypasses Esri's 5.0 prefix-only behavior
// and restores the old LIKE '%value%' contains search
quickSearch.sources = [
  {
    layer: parcelLayer,
    searchFields: ["PartyName_1"],
    displayField: "PartyName_1",
    name: "Search by Owner",
    outFields: ["PartyName_1"],
    exactMatch: false,
    suggestionsEnabled: true,
    getSuggestions: (params) => {
      const query = parcelLayer.createQuery();
      query.where = `PartyName_1 LIKE '%${params.suggestTerm.replace(/'/g, "''")}%'`;
      query.outFields = ["PartyName_1"];
      query.returnGeometry = false;
      query.returnDistinctValues = true;
      query.orderByFields = ["PartyName_1"];
      query.num = 6;
      return parcelLayer.queryFeatures(query).then(results => {
        return results.features.map(f => ({
          key: f.attributes.PartyName_1,
          text: f.attributes.PartyName_1,
          sourceIndex: params.sourceIndex
        }));
      });
    }
  },
  {
    layer: parcelLayer,
    searchFields: ["PropertyAddress"],
    displayField: "PropertyAddress",
    name: "Search by Address",
    outFields: ["PropertyAddress"],
    exactMatch: false,
    suggestionsEnabled: true,
    getSuggestions: (params) => {
      const query = parcelLayer.createQuery();
      query.where = `PropertyAddress LIKE '%${params.suggestTerm.replace(/'/g, "''")}%'`;
      query.outFields = ["PropertyAddress"];
      query.returnGeometry = false;
      query.returnDistinctValues = true;
      query.orderByFields = ["PropertyAddress"];
      query.num = 6;
      return parcelLayer.queryFeatures(query).then(results => {
        return results.features.map(f => ({
          key: f.attributes.PropertyAddress,
          text: f.attributes.PropertyAddress,
          sourceIndex: params.sourceIndex
        }));
      });
    }
  },
  {
    layer: parcelLayer,
    searchFields: ["QuickRefID_1"],
    displayField: "QuickRefID_1",
    name: "Search by Quick Reference ID",
    outFields: ["QuickRefID_1"],
    exactMatch: false,
    suggestionsEnabled: true,
    getSuggestions: (params) => {
      const query = parcelLayer.createQuery();
      query.where = `QuickRefID_1 LIKE '%${params.suggestTerm.replace(/'/g, "''")}%'`;
      query.outFields = ["QuickRefID_1"];
      query.returnGeometry = false;
      query.returnDistinctValues = true;
      query.orderByFields = ["QuickRefID_1"];
      query.num = 6;
      return parcelLayer.queryFeatures(query).then(results => {
        return results.features.map(f => ({
          key: f.attributes.QuickRefID_1,
          text: f.attributes.QuickRefID_1,
          sourceIndex: params.sourceIndex
        }));
      });
    }
  }
];

View solution in original post

0 Kudos
5 Replies
NZGIS
by
Occasional Contributor

Following this. Not sure if this is related, but we have noticed few differences as well. It seems that Search in ExP works differently to Search in Map SDK. For example, when I search "Nora", below are the results I have obtained from Search widget in Map SDK and Search widget from ExP Builder. 

Search result for "Nora" in Map SDK Search widget - https://imgur.com/a/XWumpC0

Search result for "Nora" in ExP Search widget - https://imgur.com/a/sPxLVy6

The results seem different regardless of the setting. In the ExP builder, we can see the results include the search term being in the middle of the result whereas in the Map SDK version, it always displays the start's with results. 

Discover the magic of the internet at Imgur, a community powered entertainment destination. Lift your spirits with funny jokes, trending memes, entertaining gifs, inspiring stories, viral videos, and so much more from users.
Discover the magic of the internet at Imgur, a community powered entertainment destination. Lift your spirits with funny jokes, trending memes, entertaining gifs, inspiring stories, viral videos, and so much more from users.
0 Kudos
WesleyO
Esri Contributor

@MatthewDriscoll This is the expected behavior. The change was introduced in 4.25: https://developers.arcgis.com/javascript/latest/4.25/#search-performance-improvements

 

This AGOL blog also gives additional insights into why this change may have occurred: https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/searching-for-features-in-maps-and-a...

MatthewDriscoll
MVP Alum

Is there a known fix or do I go create my own?  Seems like it makes this component pretty useless for anything other then location.  @NZGIS  this is directly related to your problem, it is prefix only now.  

WesleyO
Esri Contributor

I am not aware of any ways to adjust this through the API. However, adding "%" to the front of your search term should do the trick.

 

@NZGIS , This feature exists in ExB's Search Widget, but only as a search result rather than a search suggestion. Let me know if there are any questions on this.

MatthewDriscoll
MVP Alum

Idea thread found here.

Solution:

// Configure only your parcel layer sources
// Custom getSuggestions bypasses Esri's 5.0 prefix-only behavior
// and restores the old LIKE '%value%' contains search
quickSearch.sources = [
  {
    layer: parcelLayer,
    searchFields: ["PartyName_1"],
    displayField: "PartyName_1",
    name: "Search by Owner",
    outFields: ["PartyName_1"],
    exactMatch: false,
    suggestionsEnabled: true,
    getSuggestions: (params) => {
      const query = parcelLayer.createQuery();
      query.where = `PartyName_1 LIKE '%${params.suggestTerm.replace(/'/g, "''")}%'`;
      query.outFields = ["PartyName_1"];
      query.returnGeometry = false;
      query.returnDistinctValues = true;
      query.orderByFields = ["PartyName_1"];
      query.num = 6;
      return parcelLayer.queryFeatures(query).then(results => {
        return results.features.map(f => ({
          key: f.attributes.PartyName_1,
          text: f.attributes.PartyName_1,
          sourceIndex: params.sourceIndex
        }));
      });
    }
  },
  {
    layer: parcelLayer,
    searchFields: ["PropertyAddress"],
    displayField: "PropertyAddress",
    name: "Search by Address",
    outFields: ["PropertyAddress"],
    exactMatch: false,
    suggestionsEnabled: true,
    getSuggestions: (params) => {
      const query = parcelLayer.createQuery();
      query.where = `PropertyAddress LIKE '%${params.suggestTerm.replace(/'/g, "''")}%'`;
      query.outFields = ["PropertyAddress"];
      query.returnGeometry = false;
      query.returnDistinctValues = true;
      query.orderByFields = ["PropertyAddress"];
      query.num = 6;
      return parcelLayer.queryFeatures(query).then(results => {
        return results.features.map(f => ({
          key: f.attributes.PropertyAddress,
          text: f.attributes.PropertyAddress,
          sourceIndex: params.sourceIndex
        }));
      });
    }
  },
  {
    layer: parcelLayer,
    searchFields: ["QuickRefID_1"],
    displayField: "QuickRefID_1",
    name: "Search by Quick Reference ID",
    outFields: ["QuickRefID_1"],
    exactMatch: false,
    suggestionsEnabled: true,
    getSuggestions: (params) => {
      const query = parcelLayer.createQuery();
      query.where = `QuickRefID_1 LIKE '%${params.suggestTerm.replace(/'/g, "''")}%'`;
      query.outFields = ["QuickRefID_1"];
      query.returnGeometry = false;
      query.returnDistinctValues = true;
      query.orderByFields = ["QuickRefID_1"];
      query.num = 6;
      return parcelLayer.queryFeatures(query).then(results => {
        return results.features.map(f => ({
          key: f.attributes.QuickRefID_1,
          text: f.attributes.QuickRefID_1,
          sourceIndex: params.sourceIndex
        }));
      });
    }
  }
];
0 Kudos