Home > Enterprise >  Azure Search how to find a substring in a text field
Azure Search how to find a substring in a text field

Time:02-02

I need to filter based on a partial string contained in a specific field, regardless of their tokenization. For example, the field "file_name" contains the value "Las Vegas Brochure.pdf" and I need to retrieve this record even if I look just for "Vega". The problem is that it works just if I specify the whole word like "Vegas", as you see in the following two examples. WORKGING

DOES NOT WORK

CodePudding user response:

It's because you're using queryType=simple. Just change to queryType=full and it should work.

PS: I'm not 100% sure if filter supports Regular Expressions. I believe you must use it in the search part

e.g.

search=/.vega./&queryType=full&searchModel=all

CodePudding user response:

Another couple of examples using the search part: it works DOENS'T WORK

CodePudding user response:

Here it is, I tried all the combinations of analyzer (null and standard.lucene) for content and file_name, but it didn't change the result:

index definition

    {
  "fields": [
    {
      "name": "id",
      "type": "Edm.String",
      "facetable": false,
      "filterable": false,
      "key": true,
      "retrievable": true,
      "searchable": false,
      "sortable": false,
      "analyzer": null,
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    },
    {
      "name": "content",
      "type": "Edm.String",
      "facetable": false,
      "filterable": false,
      "key": false,
      "retrievable": true,
      "searchable": true,
      "sortable": false,
      "analyzer": "standard.lucene",
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    },
    {
      "name": "url",
      "type": "Edm.String",
      "facetable": false,
      "filterable": true,
      "key": false,
      "retrievable": true,
      "searchable": true,
      "sortable": false,
      "analyzer": null,
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    },
    {
      "name": "file_name",
      "type": "Edm.String",
      "facetable": false,
      "filterable": true,
      "key": false,
      "retrievable": true,
      "searchable": true,
      "sortable": false,
      "analyzer": null,
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    },
    {
      "name": "metadata_storage_name",
      "type": "Edm.String",
      "facetable": true,
      "filterable": true,
      "key": false,
      "retrievable": true,
      "searchable": false,
      "sortable": false,
      "analyzer": null,
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    },
    {
      "name": "metadata_storage_size",
      "type": "Edm.Int64",
      "facetable": false,
      "filterable": false,
      "retrievable": true,
      "sortable": true,
      "analyzer": null,
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    },
    {
      "name": "metadata_creation_date",
      "type": "Edm.DateTimeOffset",
      "facetable": false,
      "filterable": false,
      "retrievable": true,
      "sortable": true,
      "analyzer": null,
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    }
  ]
}

CodePudding user response:

I found it: I missed this dot. Thank you very much

right

  •  Tags:  
  • Related