php - Elasticsearch 映射整数或长整型

标签 php mysql laravel elasticsearch

我在我的 Laravel 应用程序中使用 ES 作为搜索引擎。

但是当涉及到映射时,我不确定何时使用整数或长整型来表示我的数字?

我有一个 MySql 数据库,可以将数据实时添加到我的 ES 数据库中。

我需要使我的号码可搜索或可排序。例如按价格排序或按价格搜索。

我在文档中找不到任何说明何时使用整数或长整型的内容。

提前致谢

最佳答案

int 和 long 之间的唯一区别是可以表示的数字的大小。基本上,int 是一个 32 位有符号整数,而 long 是一个 64 位有符号整数。因此,如果您需要表示的值大于 231 - 1,那么您需要使用 long。

为了确保您可以按字段搜索/排序,您需要确保它已编入索引 (not_analyzed)。

Elasticserach mapping文档。
Elasticsearch core types文档。
Java primitive types文档。

关于php - Elasticsearch 映射整数或长整型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28616659/

相关文章:

php - PHP中的套接字连接错误

php - 为初学者使用 PHP/MySQL 管理用户配置文件

html - Kendo UI 移动和 MySQL 数据库连接

twitter-bootstrap - Bootstrap javascript 加载但不工作

php - allow_url_fopen 安全吗?

php - Ajax php/mysql 在非常活跃的提要上加载更多按钮

laravel - file_put_contents(/homepages/storage/framework/views/c8d540ced881ee3d14baa6e1259a7deab143b7fa.php) : failed to open stream: No such file or directory

javascript - 如何将数组从 View 传递到 Controller ?使用 Laravel

PHP 单元 9 : Test Dependencies does not work for me

mysql - Eclipse MySQL JDBC驱动程序设置未注册驱动程序类