Accessing multi fields

I am unable to access multi fields using the navigation notation.

My mapping

{
"mappings":{
"document":{
"properties":{
"tags":{
"type":"object",
"properties":{
"title":{
"fields":{
"partial":{
"search_analyzer":"main",
"index_analyzer":"partial",
"type":"string"
},
"title":{
"type":"string",
"analyzer":"main"
},
"title2":{
"type":"string",
"analyzer":"main"
}
},
"type":"multi_field"
}
}
}
}
}
},

"settings":{
    "analysis":{
        "filter":{
            "name_ngrams":{
                "side":"front",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_ngrams_back":{
                "side":"back",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_middle_ngrams":{
                "type":"nGram",
                "max_gram":50,
                "min_gram":2
            }
        },

        "analyzer":{
            "main":{
                "filter": ["standard", "lowercase", "asciifolding"],
                "type": "custom",
                "tokenizer": "standard"
            },
            "partial":{

"filter":["standard","lowercase","asciifolding","name_ngrams"],
"type": "custom",
"tokenizer": "standard"
}
}
}
}

}

Test data

curl -XPUT localhost:9200/testindex/document/1 -d '{"title": "Fight for
your life"}'
curl -XPUT localhost:9200/testindex/document/2 -d '{"title": "Fighting for
your life"}'
curl -XPUT localhost:9200/testindex/document/3 -d '{"title": "Will you just
start the fight"}'

Search

curl -XGET
'localhost:9200/testindex/document/_search?q=title:life&pretty=1'
// Ok
curl -XGET
'localhost:9200/testindex/document/_search?q=document.title:life&pretty=1'
// Ok

// Doesn't work. I expect this to return same result as the first query.
curl -XGET 'localhost:9200/testindex/document/_search?q=title.title2
:life&pretty=1'
curl -XGET 'localhost:9200/testindex/document/_search?q=*
document.title.title2*:life&pretty=1'

My question is, how do I reference multi fields field when querying?

Thanks

--

When I say it doesn't work, I mean, it returns 0 hits.

On Sunday, 4 November 2012 02:52:17 UTC+1, Kennedy Idialu wrote:

I am unable to access multi fields using the navigation notation.

My mapping

{
"mappings":{
"document":{
"properties":{
"tags":{
"type":"object",
"properties":{
"title":{
"fields":{
"partial":{
"search_analyzer":"main",
"index_analyzer":"partial",
"type":"string"
},
"title":{
"type":"string",
"analyzer":"main"
},
"title2":{
"type":"string",
"analyzer":"main"
}
},
"type":"multi_field"
}
}
}
}
}
},

"settings":{
    "analysis":{
        "filter":{
            "name_ngrams":{
                "side":"front",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_ngrams_back":{
                "side":"back",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_middle_ngrams":{
                "type":"nGram",
                "max_gram":50,
                "min_gram":2
            }
        },

        "analyzer":{
            "main":{
                "filter": ["standard", "lowercase", "asciifolding"],
                "type": "custom",
                "tokenizer": "standard"
            },
            "partial":{

"filter":["standard","lowercase","asciifolding","name_ngrams"],
"type": "custom",
"tokenizer": "standard"
}
}
}
}

}

Test data

curl -XPUT localhost:9200/testindex/document/1 -d '{"title": "Fight for
your life"}'
curl -XPUT localhost:9200/testindex/document/2 -d '{"title": "Fighting for
your life"}'
curl -XPUT localhost:9200/testindex/document/3 -d '{"title": "Will you
just start the fight"}'

Search

curl -XGET
'localhost:9200/testindex/document/_search?q=title:life&pretty=1'
// Ok
curl -XGET
'localhost:9200/testindex/document/_search?q=document.title:life&pretty=1'
// Ok

// Doesn't work. I expect this to return same result as the first query.
curl -XGET 'localhost:9200/testindex/document/_search?q=title.title2
:life&pretty=1'
curl -XGET 'localhost:9200/testindex/document/_search?q=*
document.title.title2*:life&pretty=1'

My question is, how do I reference multi fields field when querying?

Thanks

--

Answered on
stackoverflow: elasticsearch - How to reference multi-field when building query - Stack Overflow

On Saturday, November 3, 2012 9:56:30 PM UTC-4, Kennedy Idialu wrote:

When I say it doesn't work, I mean, it returns 0 hits.

On Sunday, 4 November 2012 02:52:17 UTC+1, Kennedy Idialu wrote:

I am unable to access multi fields using the navigation notation.

My mapping

{
"mappings":{
"document":{
"properties":{
"tags":{
"type":"object",
"properties":{
"title":{
"fields":{
"partial":{
"search_analyzer":"main",
"index_analyzer":"partial",
"type":"string"
},
"title":{
"type":"string",
"analyzer":"main"
},
"title2":{
"type":"string",
"analyzer":"main"
}
},
"type":"multi_field"
}
}
}
}
}
},

"settings":{
    "analysis":{
        "filter":{
            "name_ngrams":{
                "side":"front",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_ngrams_back":{
                "side":"back",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_middle_ngrams":{
                "type":"nGram",
                "max_gram":50,
                "min_gram":2
            }
        },

        "analyzer":{
            "main":{
                "filter": ["standard", "lowercase", "asciifolding"],
                "type": "custom",
                "tokenizer": "standard"
            },
            "partial":{

"filter":["standard","lowercase","asciifolding","name_ngrams"],
"type": "custom",
"tokenizer": "standard"
}
}
}
}

}

Test data

curl -XPUT localhost:9200/testindex/document/1 -d '{"title": "Fight for
your life"}'
curl -XPUT localhost:9200/testindex/document/2 -d '{"title": "Fighting
for your life"}'
curl -XPUT localhost:9200/testindex/document/3 -d '{"title": "Will you
just start the fight"}'

Search

curl -XGET
'localhost:9200/testindex/document/_search?q=title:life&pretty=1'
// Ok
curl -XGET
'localhost:9200/testindex/document/_search?q=document.title:life&pretty=1'
// Ok

// Doesn't work. I expect this to return same result as the first query.
curl -XGET 'localhost:9200/testindex/document/_search?q=title.title2
:life&pretty=1'
curl -XGET 'localhost:9200/testindex/document/_search?q=*
document.title.title2*:life&pretty=1'

My question is, how do I reference multi fields field when querying?

Thanks

--

Thanks

On Sunday, 4 November 2012 04:27:38 UTC+1, Igor Motov wrote:

Answered on stackoverflow:
elasticsearch - How to reference multi-field when building query - Stack Overflow

On Saturday, November 3, 2012 9:56:30 PM UTC-4, Kennedy Idialu wrote:

When I say it doesn't work, I mean, it returns 0 hits.

On Sunday, 4 November 2012 02:52:17 UTC+1, Kennedy Idialu wrote:

I am unable to access multi fields using the navigation notation.

My mapping

{
"mappings":{
"document":{
"properties":{
"tags":{
"type":"object",
"properties":{
"title":{
"fields":{
"partial":{
"search_analyzer":"main",
"index_analyzer":"partial",
"type":"string"
},
"title":{
"type":"string",
"analyzer":"main"
},
"title2":{
"type":"string",
"analyzer":"main"
}
},
"type":"multi_field"
}
}
}
}
}
},

"settings":{
    "analysis":{
        "filter":{
            "name_ngrams":{
                "side":"front",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_ngrams_back":{
                "side":"back",
                "max_gram":50,
                "min_gram":2,
                "type":"edgeNGram"
            },
            "name_middle_ngrams":{
                "type":"nGram",
                "max_gram":50,
                "min_gram":2
            }
        },

        "analyzer":{
            "main":{
                "filter": ["standard", "lowercase", "asciifolding"],
                "type": "custom",
                "tokenizer": "standard"
            },
            "partial":{

"filter":["standard","lowercase","asciifolding","name_ngrams"],
"type": "custom",
"tokenizer": "standard"
}
}
}
}

}

Test data

curl -XPUT localhost:9200/testindex/document/1 -d '{"title": "Fight for
your life"}'
curl -XPUT localhost:9200/testindex/document/2 -d '{"title": "Fighting
for your life"}'
curl -XPUT localhost:9200/testindex/document/3 -d '{"title": "Will you
just start the fight"}'

Search

curl -XGET
'localhost:9200/testindex/document/_search?q=title:life&pretty=1'
// Ok
curl -XGET
'localhost:9200/testindex/document/_search?q=document.title:life&pretty=1'
// Ok

// Doesn't work. I expect this to return same result as the first
query.
curl -XGET 'localhost:9200/testindex/document/_search?q=title.title2
:life&pretty=1'
curl -XGET 'localhost:9200/testindex/document/_search?q=*
document.title.title2*:life&pretty=1'

My question is, how do I reference multi fields field when querying?

Thanks

--