`
bywei
  • 浏览: 42862 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

elasticsearch个性化搜索推荐排序插件

阅读更多

elasticsearch 插件地址 

https://coding.net/u/bywei/p/elasticsearch-feature-scoring/git

使用案例

你可以使用这个插件来计算两个特征,如相关性得分:

  • 个性化搜索;
  • 寻找类似产品;
  • 产品推荐;

从代码生成插件

  1. 混帐克隆https://git.coding.net/bywei/elasticsearch-feature-scoring.git
  2. MVN清洁套装-DskipTests
  3. 创建要素得分插件dircectoy,如$ {} ES_HOME /插件/功能得分
  4. 复制目标/发行/ elasticsearch-feature-scoring-2.1.0.zip到你的插件目录并解压
  5. 重启elasticsearch

脚本参数

  • customSortField可选,在索引来存储的文件的矢量场;
  • customSorts:**不是NULL需要customSortField **,病情,一个地图<字符串,整数>;
  • sortFields可选,条件,一个地图<字符串,整数>;
  • 版本:矢量的版本,如果不为空,则应该匹配的文件向量的版本(|,如“20170331 | 0.1”如果使用版本,该字段的值应与“$ VERSION”开始);

关于

创建一个测试指标

PUT /hotelplatform
{
  "mappings": {
    "hotelDayPrice": {
      "properties": {
        "hotelId": {
          "type": "long"
        },
        "day": {
          "type": "long"
        }
      }
    }
  },
  "settings": {
    "index": {
      "number_of_shards": 1,
      "number_of_replicas": 0
    }
  }
}

指数的一些文件

POST /hotelplatform/hotelDayPrice/1
{
  "hotelId": "32195",
  "day": "1493740800000"
}

POST /hotelplatform/hotelDayPrice/2
{
  "hotelId": "32250",
  "day": "1493740800000"
}

POST /hotelplatform/hotelDayPrice/3
{
  "hotelId": "32217",
  "day": "1493740800000"
}

正常的搜索

POST /hotelplatform/_search
{
  "query": {
    "match": {
      "hotelId": "32217"
    }
  }
}

该结果是:

{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 0.14181954,
    "hits": [
      {
        "_index": "hotelplatform",
        "_type": "hotelDayPrice",
        "_id": "2",
        "_score": 0.14181954,
        "_source": {
          "hotelId": "32250",
          "day": "1493740800000"
        }
      },
      {
        "_index": "hotelplatform",
        "_type": "hotelDayPrice",
        "_id": "1",
        "_score": 0.1273061,
        "_source": {
          "hotelId": "32195",
          "day": "1493740800000"
        }
      },
      {
        "_index": "hotelplatform",
        "_type": "hotelDayPrice",
        "_id": "3",
        "_score": 0.1273061,
        "_source": {
          "hotelId": "32217",
          "day": "1493740800000"
        }
      }
    ]
  }
}

搜索蒙山特征分数sortFields

{
  "from" : 0,
  "size" : 10,
  "query" : {
    "bool" : {
      "must" : [ {
        "term" : {
          "channelCode" : "JJ_INTEGRATION_WEIXIN"
        }
      }, {
        "term" : {
          "day" : 1493827200000
        }
      } ]
    }
  },
  "_source" : {
    "includes" : [ "hotelId", "orderScore", "hotelScore", "serviceScore"],
    "excludes" : [ ]
  },
  "sort" : [  {
    "_script" : {
      "script" : {
        "inline" : "feature-scoring",
        "lang" : "native",
        "params" : {
          "sortFields" : {
            "orderScore" : 0.3,
            "hotelScore" : 0.2,
            "serviceScore" : 0.5
          }
        }
      },
      "type" : "number",
      "reverse" : true
    }
  }]
}

其结果是:排序(orderScore * 0.3 + hotelScore * 0.2 + serviceScore * 0.5)

搜索与特征分数customSorts和customSortField

POST /hotelplatform/_search
{
  "from": 0,
  "size": 100,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "day": 1493740800000
          }
        }
      ]
    }
  },
  "_source": {
    "includes": [
      "hotelId",
      "day"
    ],
    "excludes": []
  },
  "sort": [
    {
      "_script": {
        "script": {
          "inline": "feature-scoring",
          "lang": "native",
          "params": {
            "customSortField": "hotelId",
            "customSorts": {
              "32195": 200,
              "32217": 300
            }
          }
        },
        "type": "number",
        "reverse": true
      }
    }
  ]
}

其结果是:

   {
    "took": 36,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 12,
        "max_score": null,
        "hits": [
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "32217JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "32217",
                "_parent": "32217",
                "_source": {
                    "hotelId": 32217,
                    "day": 1493740800000
                },
                "sort": [
                    1,
                    300,
                    440
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "32195JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "32195",
                "_parent": "32195",
                "_source": {
                    "hotelId": 32195,
                    "day": 1493740800000
                },
                "sort": [
                    1,
                    200,
                    554
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "32250JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "32250",
                "_parent": "32250",
                "_source": {
                    "hotelId": 32250,
                    "day": 1493740800000
                },
                "sort": [
                    1,
                    0,
                    596
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "32216JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "32216",
                "_parent": "32216",
                "_source": {
                    "hotelId": 32216,
                    "day": 1493740800000
                },
                "sort": [
                    1,
                    0,
                    646
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "32247JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "32247",
                "_parent": "32247",
                "_source": {
                    "hotelId": 32247,
                    "day": 1493740800000
                },
                "sort": [
                    1,
                    0,
                    4079
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "32219JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "32219",
                "_parent": "32219",
                "_source": {
                    "hotelId": 32219,
                    "day": 1493740800000
                },
                "sort": [
                    1,
                    0,
                    4909
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "21400JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "21400",
                "_parent": "21400",
                "_source": {
                    "hotelId": 21400,
                    "day": 1493740800000
                },
                "sort": [
                    0,
                    0,
                    1
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "22292JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "22292",
                "_parent": "22292",
                "_source": {
                    "hotelId": 22292,
                    "day": 1493740800000
                },
                "sort": [
                    0,
                    0,
                    12
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "22290JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "22290",
                "_parent": "22290",
                "_source": {
                    "hotelId": 22290,
                    "day": 1493740800000
                },
                "sort": [
                    0,
                    0,
                    18
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "21382JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "21382",
                "_parent": "21382",
                "_source": {
                    "hotelId": 21382,
                    "day": 1493740800000
                },
                "sort": [
                    0,
                    0,
                    150
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "21440JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "21440",
                "_parent": "21440",
                "_source": {
                    "hotelId": 21440,
                    "day": 1493740800000
                },
                "sort": [
                    0,
                    0,
                    488
                ]
            },
            {
                "_index": "hotelplatform",
                "_type": "hotelDayPrice",
                "_id": "20166JJ_INTEGRATION_WEIXIN1493740800000",
                "_score": null,
                "_routing": "20166",
                "_parent": "20166",
                "_source": {
                    "hotelId": 20166,
                    "day": 1493740800000
                },
                "sort": [
                    0,
                    0,
                    755
                ]
            }
        ]
    }
}

个性化搜索案例的详细情况

锦江App应用

分享到:
评论

相关推荐

    elasticsearch-6.8.0+elasticsearch-analysis-ik-6.8.0 .zip

    - **推荐系统**:基于用户行为数据,构建个性化推荐模型。 通过将 Elasticsearch 与 Java 和 Spring Boot 集成,可以快速构建高性能的搜索引擎应用,满足实时数据处理和复杂查询的需求。同时,Elasticsearch 的灵活...

    elasticsearch-learning-to-rank-es_7_6_2.zip

    《Elasticsearch学习之路:深入理解Ranking机制》 ...通过深入理解和熟练运用LTR,我们可以构建出更加智能、个性化的搜索引擎,提升用户搜索体验。在实际应用中,不断探索和优化模型,将是持续提升搜索服务质量的关键。

    sort-script:elasticsearch排序脚本

    在Elasticsearch中,排序是数据检索的重要环节,它决定了搜索结果按照怎样的顺序呈现给用户。"sort-script:elasticsearch排序脚本"这个主题聚焦于如何通过自定义脚本来扩展Elasticsearch的排序功能。SortScript是一...

    Java_Elasticsearch在动作书.zip

    - 推荐系统:结合机器学习,使用Elasticsearch构建个性化推荐算法。 - 电商搜索:实现商品搜索,支持多条件筛选、排序和高亮。 以上内容仅是《Java Elasticsearch实战》一书的部分精华,深入学习和实践将帮助...

    PyPI 官网下载 | elasticsearch-django-5.1.tar.gz

    3. **推荐系统**: 基于用户行为和内容特征,实现个性化推荐。 4. **实时监控**: 监控系统指标,实时报警和故障定位。 总结,`elasticsearch-django-5.1.tar.gz`是将Elasticsearch的强大搜索功能引入Django应用的一...

    elasticsearch-head.zip

    9. **自定义配置**:Elasticsearch-Head允许通过修改配置文件来定制界面显示和连接参数,满足个性化需求。 总的来说,Elasticsearch-Head作为一款轻量级的管理工具,能够帮助开发者和运维人员更便捷地管理Elastic...

    Introduction to Search with Sphinx

    而且它还支持对搜索结果进行排序和过滤,以确保用户得到更加精确和个性化的搜索体验。 此外,Sphinx的扩展性好,可以通过插件进行各种定制化的扩展,以适应不同场景下的特殊需求。例如,可以集成机器学习算法,使...

    基于PHP的开源搜索引擎整合系统 Seeknove.zip

    这个系统允许开发者或者网站管理员将多个搜索引擎如Google、Bing、Elasticsearch等进行统一的配置和调用,从而提升用户的搜索体验。下面将详细探讨 Seeknove 的主要功能、架构、开发环境以及其在实际应用中的价值。 ...

    EasySave3.0.7z unity很多人使用的 数据保存插件

    - **用户设置**:保存和加载用户的个性化设置,如音量、分辨率等。 - **高分榜管理**:自动保存并排序高分记录,展示在游戏排行榜上。 - **云存档**:配合云服务,实现游戏数据的云端同步,用户可以在不同设备间...

    9ES (9gag Enhancement Suite)-crx插件

    总的来说,9ES (9gag Enhancement Suite) crx插件是9gag用户的理想伴侣,它通过一系列增强功能,旨在提供一个更舒适、更个性化的浏览体验。然而,具体的功能集需要通过安装和实际使用才能完全了解。由于这是一款第三...

    人工智能-项目实践-信息检索-文献检索系统界面

    同时,推荐系统可以利用协同过滤或基于内容的算法,根据用户的检索历史和个人偏好,提供个性化推荐。 系统的界面设计应当简洁明了,易于操作。用户应能方便地输入查询条件,选择检索范围(如特定年份、作者或期刊)...

    lucene in action

    - **扩展搜索功能**:通过实现自定义搜索器、评分函数等方式可以为 Lucene 添加更多个性化功能。 - **文档格式解析**:对于需要索引多种格式文档的情况,可以利用 Lucene 内置或第三方提供的文档解析工具。 #### ...

    基于PHP的多彩贴吧(phpcolor)v4.0Beta源码.zip

    为了方便用户查找相关信息,phpcolor可能集成了全文搜索功能,这可能涉及到了SQL的LIKE操作或者更复杂的全文索引技术如Sphinx或Elasticsearch。 7. 插件与主题系统: 为增强用户体验和个性化,phpcolor可能会有...

    Java开源的下一代社区平台Symphony.zip

    也可以自己搭建 Elasticsearch 并通过配置进行集成 后续会对搜索功能进行加强,实现条件过滤,结果高亮等,敬请期待。 计划中的特性 信任系统 通过历史数据对用户进行分级提权,让用户从浏览者逐步变为参与者...

Global site tag (gtag.js) - Google Analytics