Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot filter, sort, or aggregate on _type. #5684

Closed
xuzha opened this issue Dec 14, 2015 · 20 comments
Closed

Cannot filter, sort, or aggregate on _type. #5684

xuzha opened this issue Dec 14, 2015 · 20 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience

Comments

@xuzha
Copy link

xuzha commented Dec 14, 2015

There are a few Found customers find that they cannot filter on _type.
I could reproduce it with a simple clean index. (es 2.1, Kibana 4.3).

I think this might be a bug.

screen shot 2015-12-14 at 14 49 36

Discuss issue link : https://discuss.elastic.co/t/elasticsearch-2-0-with--type-not-indexed/35244/10

@xuzha xuzha added bug Fixes for quality problems that affect the customer experience v4.3.0 labels Dec 14, 2015
@johncollaros
Copy link

I have encountered this bug too after upgrading from ES1.7.x ->2.1 and Kibana 4.2 -> 4.3.1

All existing index patterns have _type as indexed.
Any new indices created after the upgrade sets _type indexed: false.
Looking in the .kibana index-patterns reveals this.

{
  "_index": ".kibana",
  "_type": "index-pattern",
  "_id": "newindex_2-*",
  "_version": 23,
  "found": true,
  "_source": {
    "title": "newindex_2-*",
    "timeFieldName": "@timestamp",
    "fields": "[{"name":"_id","type":"string","count":0,"scripted":false,"indexed":false,"analyzed":false,"doc_values":false},
{"name":"_type","type":"string","count":0,"scripted":false,"indexed":false,"analyzed":false,"doc_values":false},
{"name":"_score","type":"number","count":0,"scripted":false,"indexed":false,"analyzed":false,"doc_values":false}]"
  }
}

I tried updating the value using Elasticsearch API to modify .kibana index settings. After reloading kibana web page, this worked.
However, when refreshing the field list from the Settings->Indices tab, _type is updated back to false.

Refreshing field values for an old index where _type was set to indexed, _type stayed as indexed:true.

This is looking to be more of an ES bug that is affecting Kibana.

Using the _mapping API on an old index returned the following:

/oldindex-2014.12.28/_mapping/logs/field/_type?include_defaults=true

{
  "oldindex-2014.12.28": {
    "mappings": {
      "logs": {
        "_type": {
          "full_name": "_type",
          "mapping": {
            "_type": {
              "store": false,
              "index": "not_analyzed"
            }
          }
        }
      }
    }
  }
}

On the new index:
/newindex_2-2015.01.01/_mapping/logs/field/_type?include_defaults=true

{
  "newindex_2-2015.01.01": {
    "mappings": {
      "logs": {
        "_type": {
          "full_name": "_type",
          "mapping": {

          }
        }
      }
    }
  }
}

Looks like something has changed with ES 2.x. The mapping entity is empty, preventing Kibana from detecting the _type field as indexed.

So a workaround is to manually update the .kibana/index-patterns using the Elasticsearch API.

@aliostad
Copy link

Guys this is a complete bummer. I commonly use _type. Can we please get a resolution? It seems the fixing of this keeps getting postponed.

@johncollaros
Copy link

I got a reply on elasticsearch issue i raised: elastic/elasticsearch#16389 (comment)
Seems like the mapping api is never going to return any values for _metafields anymore and it was suggested that kibana needs to hardcode these values now.

There is a way around this. You need to edit the .kibana data..see my post on this discuss
https://discuss.elastic.co/t/elasticsearch-2-0-with--type-not-indexed/35244/20

@aliostad
Copy link

👍 Nice! @johncollaros

@epixa
Copy link
Contributor

epixa commented Mar 10, 2016

It sounds like same issue described in #5634

@rashidkpc rashidkpc changed the title Cannot filter on _type column. Cannot filter or aggregate on _type. Mar 10, 2016
@rashidkpc
Copy link
Contributor

As noted, this is being caused by a change to the Elasticsearch API that removes the returning of mappings for Elasticsearch metadata fields: elastic/elasticsearch#16389 (comment). I weighed in on that as I don't think its a good idea for us to hard code the abilities of those fields as they may change over time, as they have in the past. I'd prefer the Elasticsearch API informed us of the field's capabilities

@pemontto
Copy link

👍

@jconlon
Copy link

jconlon commented Apr 12, 2016

What's the point of having types if you can't filter on them? I went to the trouble of working out datatyping and mapping for my documents before indexing several different types of them.

Will this be fixed anytime soon in Kibana or do we have to either use the workaround (thanks for it doing it johncollaros) or redesign our our schemas by adding an extra type field?

Seems as though the workaround is also problematic as a user could reset Kibana and put it back into the broken state?

@dkulichkin
Copy link

It could be 100% done when sending a request manually, +1 for having a workaround for this feature,
Many thanks

@wusthuke
Copy link

wusthuke commented Aug 3, 2016

@johncollaros the method of eidt .kibana workd fine, but when i refresh in kibana (Settings --> Inidces --> refresh button), _type indexed change back to false. I used elasticsearch-2.3.3、kibana-4.5.2, is the kibana bug not fixed yet?

@orphaner
Copy link

👍

@johncollaros
Copy link

@wusthuke yes, if you ever use the refresh button in kibana it will undo the workaround. I've done a clean install of es 2.3.4 and kibana 4.5.4 and this is still broken.

@johncollaros
Copy link

Is anything being done to fix this issue in pre 5 releases?

@hummingV
Copy link

hummingV commented Aug 23, 2016

I could type in the filter manually in the search bar like this
_type: "typename"
It works without editing kibana index patterns. Doesn't have to worry about refresh index button either. It is indeed lame to have to type that in though.

@LeeDr
Copy link

LeeDr commented Aug 24, 2016

I think this is the same issue with users trying to filter or aggregate on _index.

I documented here how a user could aggregate on _index by editing the visualizations visState query;
https://discuss.elastic.co/t/how-to-apply-different-filter-for-different-column-in-a-single-kibana-visualisation-data-table/58817/2

I understand the reluctance to hard-code _type and _index into the Kibana lists, but it seems they're pretty standard in Elasticsearch and probably won't go away any time soon (and lots of stuff would break if they did). If we don't, users will have to do hacks like this.

@qraynaud
Copy link

qraynaud commented Oct 24, 2016

Yes I agree. Plus it will always be possible to deduce the capability using the ES cluster version. If it changes, it should not be hard to say, for every version < 5.x.y, then it is indexed, after it is not anymore.

I think this should be a blocker for 5.0.0 so we don't get this for the next big release.

@LeeDr
Copy link

LeeDr commented Oct 24, 2016

Adding a scripted field type seems to help in a few cases.

  1. Create a scripted field (I named it type)
  2. Language = painless
  3. Type = string
  4. Format = - default -
  5. Popularity = 0
  6. Script = doc['_type'].value

image

From Discover tab I can add both fields to my document list under the histogram.

I can sort on my scripted type field but not on the _type field.

I can search on _type:logs but not on type:logs

I can filter on type:"logs" but not on _type

I get 2 warnings on Discover when I mouse over Visualize on _type;
1- Doc values are not enabled on this field. This may lead to excess heap consumption when visualizing.
2- This field is not indexed and might not be usable in visualizations.

I get 1 warning when I mouse over Visualize on my scripted type field Scripted fields can take a long time to execute.

In a Vertical Bar Chart Terms aggregation I see both _type and type and both return the same results. I can't tell any performance difference with my small data set.

Refreshing the index pattern does not remove the scripted field.

@Bargs
Copy link
Contributor

Bargs commented Jan 13, 2017

Thanks to updates to the field stats API in ES 5.0 _type is now aggregatable. I think filtering and sorting should be possible as well, I'll need to look into the code that's blocking it at the moment.

screen shot 2017-01-13 at 4 02 13 pm

@Bargs Bargs changed the title Cannot filter or aggregate on _type. Cannot filter, sort, or aggregate on _type. Jan 13, 2017
Bargs added a commit that referenced this issue Feb 13, 2017
It was already possible to sort, aggregate, and filter on _type in ES but we didn't allow it in Kibana because Elasticsearch's APIs pre-5.0 didn't report mapping information for meta fields. Now that field stats returns searchable and aggregatable (including meta fields) we can safely determine if any field is filterable, sortable, or aggregatable without looking at the mappings. This PR simply includes the searchable and aggregatable information in the calculations that determine filterable and sortable status of a field.

Fixes #5684
@ytzlax
Copy link
Contributor

ytzlax commented Mar 28, 2017

@Bargs , I using kibana 5.1.2, I can create visualization of _type field, but when I filtering I get "_type field can not be used for filtering" error

@Bargs
Copy link
Contributor

Bargs commented Mar 28, 2017

@ytzlax this will be fixed in 5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience
Projects
None yet
Development

No branches or pull requests