0
votes

I'm testing the following query in Azure Search portal but is not giving me the expected results. I want as result any document having at least one ocurrence of algo word.

search=algo&queryType=full&searchMode=any

Important: MyVal is Searchable and have Lucene Analyzer (spanish)

Expected element result:

{
    "@odata.context": "https://....windows.net/indexes(....)/$metadata#docs(*)",
    "value": [
        {
            "MyKey":"1",
            "MyValues":[
                {
                    "MyVal":"algo aqui"
                },
                {
                    "MyVal":"lala"
                },
            ]
        }
    ]
}

NOT expected element result:

{
    "@odata.context": "https://....windows.net/indexes(....)/$metadata#docs(*)",
    "value": [
        {
            "MyKey":"1",
            "MyValues":[
                {
                    "MyVal":"algoOtherStuff aqui"
                },
                {
                    "MyVal":"lala"
                },
            ]
        }
    ]
}

Result got:

{
    "@odata.context": "https://....windows.net/indexes(....)/$metadata#docs(*)",
    "value": []
}

More example queries and results

search=algo*&queryType=full&searchMode=any

[No results]


search=/.algo./&queryType=full&searchMode=any

[No results]


search=algo aqui&queryType=full&searchMode=any

[EXPECTED RESULT!!!] (element found)


search=aqui&queryType=full&searchMode=any

[EXPECTED RESULT!!!] (element found)


IMPORTANT: If I change the words for two others to test like: "some data" or "something special" and search by one of those, Azure Search is returning the expected results. Seems like a problem with "algo" particular word.

1
Just to check you do have docs in your index and what shape results will take, can you do a search for "*"?Bertrand Le Roy
@BertrandLeRoy sure, I'm able to find those documents with no filters search or by its own keysgsubiran
OK, I don't see anything obviously wrong here, so I'd try maybe "some*" next to see if you still have results?Bertrand Le Roy
@BertrandLeRoy It's weird, I changed to other words and don't have any problem. I posted not real words cause are in other language (spanish) but it seems that is something related to this specific phrase/word. I will update question with real words.gsubiran
@BertrandLeRoy I've updated question with relevant infogsubiran

1 Answers

2
votes

Ok, I was able to reproduce the problem with the following code:

var client = new SearchServiceClient("xxxx", new SearchCredentials("abcabc"));

            client.Indexes.Create(new Microsoft.Azure.Search.Models.Index
            {
                Name = "index",
                Fields = new List<Field>
                {
                    new Field("Id", DataType.String){ IsKey = true, IsRetrievable = true, IsFilterable = true},
                    Field.NewComplex("MyValues", true, new List<Field> { new Field("MyVal", DataType.String)
                        {
                            IsRetrievable = true,
                            IsFilterable = true,
                            IsSearchable =true,
                            Analyzer = AnalyzerName.EsLucene
                        }
                    })
                }
            });

            var docs = new List<CustomDoc> {
                new CustomDoc { Id = "1", MyValues = new MyValues[] { new MyValues { MyVal = "algo aqui" }, new MyValues { MyVal = "lala" }} },
                new CustomDoc { Id = "2", MyValues = new MyValues[] { new MyValues { MyVal = "something else" }, new MyValues { MyVal = "xxx" }} },
            };

            var indexClient = client.Indexes.GetClient("index");
            indexClient.Documents.Index(IndexBatch.Upload(docs));

And yes, you were right. "Algo" is considered a stop word in the StandardLucene analyzer (spanish) :

https://github.com/apache/lucene-solr/blob/master/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/spanish_stop.txt

Changing to EsMicrosoft analyzer returns searches for "algo":

client.Indexes.Create(new Microsoft.Azure.Search.Models.Index
            {
                Name = "index",
                Fields = new List<Field>
                {
                    new Field("Id", DataType.String){ IsKey = true, IsRetrievable = true, IsFilterable = true},
                    Field.NewComplex("MyValues", true, new List<Field> { new Field("MyVal", DataType.String)
                        {
                            IsRetrievable = true,
                            IsFilterable = true,
                            IsSearchable =true,
                            Analyzer = AnalyzerName.EsMicrosoft
                        }
                    })
                }
            });