Solr Facet only on Date excluding time

十年热恋 提交于 2019-12-10 22:55:30

问题


I am trying to do a facet pivot on two fields timestamp and price and here is how my solr query is: http://localhost:8888/solr/collection1/select?q=description%3laptop&wt=json&indent=true&facet=true&facet.pivot=timestamp,price&stats=true&stats.field=price&stats.facet=timestamp

This gives me the result as:

*"timestamp,price":[{
          "field":"timestamp",
          "value":"2015-06-02T07:12:29.044Z",
          "count":50,
          "pivot":[{
              "field":"price",
              "value":389.0,
              "count":9},
            {
              "field":"price",
              "value":388.0,
              "count":4},
            {
              "field":"price",
              "value":300.0.....*

I would like to change the timestamp format from 2015-06-02T07:12:29.044Z to 2015-06-02 when doing the facet so that the results come back as:

*"timestamp,price":[{
          "field":"timestamp",
          "value":"2015-06-02",
          "count":50,
          "pivot":[{
              "field":"price",
              "value":389.0,
              "count":9},
            {
              "field":"price",
              "value":388.0,
              "count":4},
            {
              "field":"price",
              "value":300.0.....*

So it facets by a day instead of multiple times a day. Is this possible?


回答1:


an easy solution (but needs reindexing) is to put the date only value in another field (you can use this update processor for this, or do it on the client side if you prefer), and then facet on that field.



来源:https://stackoverflow.com/questions/44644034/solr-facet-only-on-date-excluding-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!