小编Luk*_*ins的帖子

Nginx - 将所有404错误传递回PHP-FPM以进行自定义错误页面处理

我知道这已被问了一千次,但我找到的所有答案根本不起作用(对我来说或通常是这些问题的原始OP)......所以,我会试着解释这个问题我尽可能最好,希望我们可以让它为我和其他曾经问过的人工作.

我的Nginx配置(删除了许多其他不相关的东西)如下:

http {
    # Config from here removed

    server {
            listen 80;
            listen 443 ssl;
            server_name mydomain.co.uk;

            ssl_certificate /xxxxxxx.crt;
            ssl_certificate_key /xxxxxxx.key;

            # Custom error pages
            root /var/www/viovet_frontend;
            error_page 404 = /error404.php;

            # Any simple .php page
            location ~ \.php$ {
                    root /var/www/xxxxxx;
                    #index index.php index.html;

                    include /etc/nginx/fastcgi.conf;
                    fastcgi_pass phpfastcgiservers;
                    include fastcgi_params;

                    fastcgi_intercept_errors on;
            }

            # Lots more config and re-write rules here removed
    }

    upstream phpfastcgiservers {
            server xxxxx1:9001;
            server xxxxx2:9001;
            server xxxxx3:9001;
            fair;
    }
}
Run Code Online (Sandbox Code Playgroud)

我所要做的就是让Nginx捕获所有404并将它们发送回PHP-FPM,location ~ …

php nginx http-status-code-404

9
推荐指数
1
解决办法
2万
查看次数

从PHP中的键列表创建新数组

我想要一种快速简单的方法来复制数组,但能够指定我想要复制的数组中的哪些键.

我可以轻松地为此编写一个函数,但我想知道是否有PHP函数已经执行此操作.类似array_from_keys()下面的功能.

$sizes = array('small' => '10px', 'medium' => '12px', 'large' => '13px');

$chosen = array_from_keys($sizes, 'small', 'large');

// $chosen = array('small' => '10px', 'large' => '13px');
Run Code Online (Sandbox Code Playgroud)

php arrays

5
推荐指数
3
解决办法
8468
查看次数

根据字段值相对于其他匹配文档的字段值调整Elasticsearch _score

我们正在将搜索系统从Solr升级到Elasticsearch。我们已经改善了很多事情,但是还没有解决的事情是通过产品(这是一个电子商务网站)的普及度来提高文档(产品)的得分。

这是我们目前所拥有的(删除了许多无关的位):

{
    "query": {
        "function_score": {
            "query": {
                "multi_match" : {
                    "query":    "renal dog food",
                    "fields": [ "family_name^20", "parent_categories^2", "description^0.2", "product_suffixes^8", "facet_values^5" ],
                    "operator":   "and",
                    "type":       "best_fields",
                    "tie_breaker": 0.3

                }
            },
            "functions": [{
                "script_score": {
                    "script": "_score * log1p(1 + doc['popularity_score'].value)"
                }
            }],
            "score_mode": "sum"
        }
    },
    "sort": [
        { "_score": "desc" }
    ],
}
Run Code Online (Sandbox Code Playgroud)

popularity_score字段包含最近6周内包含此商品的订单总数。一些项目将永远不会订购,而一些项目将达到30,000个(随着我们继续发展业务,可能还会更多)。这是相当大的范围。

我们遇到的问题是,文档(产品)在文本方面可能非常匹配,但并不十分流行。然后,我们还有另一个与查询不完全相关的产品,它与查询匹配,但是由于它非常受欢迎,因此它跳到了榜单上。我们正在寻找的是一种popularity_score相对于popularity_score其他匹配结果可以采用并获得某种形式的规范化的东西,而不仅仅是按原样进行(log1p有时似乎不够用)。有人有任何建议或想法吗?

谢谢!

popularity ranking elasticsearch

5
推荐指数
0
解决办法
374
查看次数

Elasticsearch错误-未为[查询]注册任何查询

我希望有人能提供帮助,当我尝试查询Elasticsearch时遇到以下错误

No query registered for [query]
Run Code Online (Sandbox Code Playgroud)

我正在使用的查询是:

{
    "query": {
        "bool": {
            "must": {
                "terms": {
                    "facet_1": [
                        "1",
                        "2"
                    ]
                },
                "function_score": {
                    "query": {
                        "multi_match": {
                            "query": "fat dog food",
                            "fields": [
                                "family_name^20",
                                "parent_categories^2",
                                "description^0.2",
                                "product_suffixes^8",
                                "facet_values^10"
                            ],
                            "operator": "and",
                            "type": "best_fields",
                            "tie_breaker": 0.3
                        }
                    },
                    "functions": [
                        {
                            "script_score": {
                                "script": "_score + ((_score * 0.3) + (log(1 + doc[\"popularity_score\"].value) * 2))"
                            }
                        }
                    ],
                    "score_mode": "sum"
                }
            },
            "must_not": {
                "terms": {
                    "facet_1": [
                        "8"
                    ] …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

0
推荐指数
1
解决办法
4124
查看次数