Weird Results with Pattern Analyzer

Hello,

We have the following Tokenizers

"tokenizer": {
"starts_with_tokenizer": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "10"
},
"ngrams_tokenizer": {
"token_chars": [
"letter",
"digit"
],
"min_gram": "1",
"type": "edge_ngram",
"max_gram": "10"
}
}

We have the following analyzers

"analyzer": {
"ngrams_analyzer": {
"filter": [
"lowercase"
],
"type": "custom",
"tokenizer": "ngrams_tokenizer"
},
"starts_with_analyzer": {
"filter": [
"lowercase"
],
"type": "custom",
"tokenizer": "starts_with_tokenizer"
},
"keyword_lowercase_analyzer": {
"filter": [
"lowercase"
],
"type": "custom",
"tokenizer": "keyword"
},
"alphanumeric_analyzer": {
"lowercase": "true",
"pattern": "[^a-zA-Z0-9áéíñóúüÁÉÍÑÓÚÜàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒäöüßÄÖÜẞàèéìíîòóùúÀÈÉÌÍÎÒÓÙÚ]",
"type": "pattern"
}
}

And we have the following mappings

"fileName": {
"type": "text",
"fields": {
"alphanumeric": {
"analyzer": "alphanumeric_analyzer",
"type": "text"
},
"lowercase": {
"analyzer": "keyword_lowercase_analyzer",
"type": "text"
},
"ngrams": {
"analyzer": "ngrams_analyzer",
"type": "text"
},
"keyword": {
"type": "keyword"
},
"starts_with": {
"analyzer": "starts_with_analyzer",
"type": "text"
}
}
}

We indexed the below file name

RBK-CAT-CAT=CN6468_P20z1_ab44_01.jpg

Scenario 1
For the scenario, the below query returns results
{
"timeout": "1m",
"from": 0,
"size": 12,
"sort": [
{
"sortKey": {
"order": "asc"
}
}
],
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"terms": {
"jobFolderID": [
1316539,
1317448
]
}
},
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"match": {
"fileName.ngrams": {
"query": "rbk",
"operator": "and"
}
}
},
{
"match": {
"fileName.ngrams": {
"query": "cat",
"operator": "and"
}
}
},
{
"match": {
"fileName.ngrams": {
"query": "cat",
"operator": "and"
}
}
},
{
"match": {
"fileName.alphanumeric": {
"type": "phrase_prefix",
"query": "cn6468_p20z1_ab44"
}
}
}
]
}
}
]
}
}
]
}
}
]
}
}
}

However, the below query does not return any result

{
"timeout": "1m",
"from": 0,
"size": 12,
"sort": [
{
"sortKey": {
"order": "asc"
}
}
],
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"terms": {
"jobFolderID": [
1316539,
1317448
]
}
},
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"match": {
"fileName.ngrams": {
"query": "rbk",
"operator": "and"
}
}
},
{
"match": {
"fileName.ngrams": {
"query": "cat",
"operator": "and"
}
}
},
{
"match": {
"fileName.ngrams": {
"query": "cat",
"operator": "and"
}
}
},
{
"match": {
"fileName.alphanumeric": {
"type": "phrase_prefix",
"query": "cn6468_p20z1_ab4"
}
}
}
]
}
}
]
}
}
]
}
}
]
}
}
}

Scenario 2
Some of the sample phrase_prefix queries that do not return results are :slight_smile:

"match": {
"fileName.alphanumeric": {
"type": "phrase_prefix",
"query": "cn6468_p20z1_ab"
}
}

"match": {
"fileName.alphanumeric": {
"type": "phrase_prefix",
"query": "cn6468_p20z1_a"
}
}

Question

  1. How this actually works?
  2. Why I do not get some of the search-as-you-type type of queries?

Please help me to understand how this fileName.alphanumeric query works.

Thanks in advance.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.