Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:51:27+00:00 2026-06-10T11:51:27+00:00

I have some problem with facets tokenize tags with spaces. I have the following

  • 0

I have some problem with facets tokenize tags with spaces.

I have the following mappings:


    curl -XPOST "http://localhost:9200/pictures" -d '
    {
      "mappings" : {
        "pictures" : {
                "properties" : {
                    "id": { "type": "string" },
                    "description": {"type": "string", "index": "not_analyzed"},
                    "featured": { "type": "boolean" },
                    "categories": { "type": "string", "index": "not_analyzed" },
                    "tags": { "type": "string", "index": "not_analyzed", "analyzer": "keyword" },
                    "created_at": { "type": "double" }
                }
            }
        }
    }'

And My Data is:


    curl -X POST "http://localhost:9200/pictures/picture" -d '{
      "picture": {
        "id": "4defe0ecf02a8724b8000047",
        "title": "Victoria Secret PhotoShoot",
        "description": "From France and Italy",
        "featured": true,
        "categories": [
          "Fashion",
          "Girls",
        ],
        "tags": [
          "girl",
          "photoshoot",
          "supermodel",
          "Victoria Secret"
        ],
        "created_at": 1405784416.04672
      }
    }'

And My Query is:


    curl -X POST "http://localhost:9200/pictures/_search?pretty=true" -d '
    {
      "query": {
        "text": {
          "tags": {
            "query": "Victoria Secret"
          }
        }
      },
      "facets": {
        "tags": {
          "terms": {
            "field": "tags"
          }
        }
      }
    }'

The Output result is:


    {
      "took" : 1,
      "timed_out" : false,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "failed" : 0
      },
      "hits" : {
        "total" : 0,
        "max_score" : null,
        "hits" : [ ]
      },
      "facets" : {
        "tags" : {
          "_type" : "terms",
          "missing" : 0,
          "total" : 0,
          "other" : 0,
          "terms" : [ ]
        }
      }
    }

Now, I got total 0 in facets and total: 0 in hits
Any Idea Why its not working?
I know that when I remove the keyword analyzer from tags and make it “not_analyzed” then I get result.

But there is still a problem of case sensitive.
If I run same above query by removing the keyword analyzer then I get the result which is:


    facets: {
        tags: {
            _type: terms
            missing: 0
            total: 12
            other: 0
            terms: [
                {
                    term: photoshoot
                    count: 1
                }
                {
                    term: girl
                    count: 1
                }
                {
                    term: Victoria Secret
                    count: 1
                }
                {
                    term: supermodel
                    count: 1
                }         
            ]
        }

    }

Here Victoria Secret is case sensitive in “not_analyzed” but it takes space in count, but when I query with lowercase as “victoria secret” it doesn’t give any results.


Any suggestions??

Thanks,
Suraj

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:51:29+00:00Added an answer on June 10, 2026 at 11:51 am

    The first examples are not totally clear to me. If you use the KeywordAnalyzer it means that the field will be indexed as it is, but then it makes much more sense to just not analyze the field at all, which is the same. The mapping you posted contains both

    "index": "not_analyzed", "analyzer": "keyword"
    

    which doesn’t make a lot of sense. If you are not analyzing the field why would select an analyzer for it?

    Apart from this, of course if you don’t analyze the field the tag Victoria Secret will be indexed as it is, thus the query victoria secret won’t match. If you want it to be case-insensitive you need to define a custom analyzer which uses the KeyworkTokenizer, since you don’t want to tokenize it and the LowercaseTokenFilter. You can define a custom analyzer through the index settings analysis section and then use it in your mapping. But that way the facet would be always lowercase, which is something that you don’t like I guess. That’s why it’s better to define a multi field and index the field using two different text analysis, one for the facet and one for search.

    You can create the index like this:

    curl -XPOST "http://localhost:9200/pictures" -d '{
        "settings" : {
            "analysis" : {
                "analyzer" : {
                  "lowercase_analyzer" : {
                    "type" : "custom",
                    "tokenizer" : "keyword",
                    "filter" : [ "lowercase"]
                  }
                }
            }
        },
        "mappings" : {
            "pictures" : {
                "properties" : {
                    "id": { "type": "string" },
                    "description": {"type": "string", "index": "not_analyzed"},
                    "featured": { "type": "boolean" },
                    "categories": { "type": "string", "index": "not_analyzed" },
                    "tags" : {
                        "type" : "multi_field",
                        "fields" : {
                            "tags": { "type": "string", "analyzer": "lowercase_analyzer" },
                            "facet": {"type": "string", "index": "not_analyzed"},
                        }
                    },
                    "created_at": { "type": "double" }
                }
            }
        }
    }'
    

    Then the custom lowercase_analyzer will be applied by default to the text query too when you search on that field, so that you can either search for Victoria Secret or victoria secret and get the result back. You need to change the facet part and make the facet on the new tags.facet field, which is not analyzed.

    Furthermore, you might want to have a look at the match query since the text query has been deprecated with the latest elasticsearch version (0.19.9).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem with Jquery Autocomplete plugin ( http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ ) I got it
I have some problem to get the utf-8 string from PHP using jQuery $.load()
I have some problem with the cursor when using JOprionPane. I set a cursor
I have some problem. Dialog.dismiss() does not work. I want to input ip, username,
I have some problem with this mongoid. It's my first time to use mongoDB,
I have some problem with MySQL Workbench in that I sometimes can't set foreign
I have some problem in my JDBC code. I am trying to connect through
I have some problem with Emit mapper when I try to save in database
I have some problem with displaying emoji icon in Android TextView First, I found
I have some problem with my code public IQueryable<PageItems> GetPageById(Guid Id) { var xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.