0
votes

I am currently using Azure Search to bring back images stored in blob storage, based off filters that are passed in by the user. Below is my Azure Search, which I thought should filter all of the content specified in the tags field as a AND:

search=foreignId:d0c41422-acfa-4e4b-a9db-8c06b6860f3f, tags:SiteRef +\""TY0033"\" + BlockRef + \""00"\" + Disipline + \""FABRIC"\"&searchMode=all&queryType=full

and what it brings back (which is wrong as you can see from the BlockRef, though if I pass CN0001, it brings the correct values):

"foreignId": "d0c41422-acfa-4e4b-a9db-8c06b6860f3f",
        "description": "Health & Safety Eire - Site Photo - TY0033-01- 
FABRIC-005",
        "fileName": "TY0033-01-FABRIC-005",
        "fileExtension": ".jpg",
        "createdAt": "26/11/2018 02:00:24",
        "tags": "[{\"TagName\":\"SiteRef\",\"Value\":\"TY0033\"},{\"TagName\":\"BlockRef\",\"Value\":\"01\"},{\"TagName\":\"Disipline\",\"Value\":\"FABRIC\"},{\"TagName\":\"PhotoNumber\",\"Value\":\"005\"}]",
        "longitude": 0,
        "latitude": 0

95% of the time this is working perfectly, however the other 5% of the time, the images comes back incorrect, as Azure search has given the incorrect details.

I have checked and it seems to be because it is not respecting the multiplicity of the search terms. I am new to Azure Search, so I am wondering if I am doing it correctly?

Any help would be greatly appreciated

Index Definition:

Index Definition

Edit: Updated Post with index definition

1
Can you share your index definition?Jacob Jedryszek
Hi Jacob, I have edited the OP with the index definition, hope this helps.C. Brindle

1 Answers

0
votes

In your query you check if foreignId is equal to d0c41422-acfa-4e4b-a9db-8c06b6860f3f and tags field contains SiteRef and if any searchable field contains TY0033, BlockRef, 00, Disipline and FABRIC. In your case all fields are searchable. Thus:

forignId matches tags contains SiteRef TY0033, BlockRef, Disipline and FABRIC are in tags field 00 is in createdAt field, as standard Lucene analyzer tokenizes "26/11/2018 02:00:24" into 26,11,2018,02,00,24

In order to search in tags field you should rewrite your query as follows:

search=foreignId:d0c41422-acfa-4e4b-a9db-8c06b6860f3f AND tags:(SiteRef AND \""TY0033"\" AND BlockRef AND \""00"\" AND Disipline AND \""FABRIC"\")&searchMode=all&queryType=full

It might be worthwhile to use proximity search to make sure you correlate occurrences field/value pairs, e.g.: BlockRef and 00 e.g., "BlockRef 00"~1