Support » Plugin: ElasticPress » ElasticPress returns recent posts instead of related posts

  • Resolved devmania

    (@devmania)


    I have the following environment up and running:

    Windows 10, XAMPP, WordPress Site, ElasticSearch.
    ElasticSearch is working correctly in http://localhost:9200/.
    I installed the plugin ElasticPress, configured it and indexed all my posts.
    I tried the widget “Related Articles” of ElasticPress, but it always returns the recent posts.

    > Here’s the copied CURL command:

    curl -XPOST -H 'Content-Type: application/json' -d '{"from":0,"size":5,"sort":[{"post_date":{"order":"desc"}}],"query":{"more_like_this":{"like":{"_id":102},"fields":["post_title","post_content","terms.post_tag.name"],"min_term_freq":1,"max_query_terms":12,"min_doc_freq":1}},"post_filter":{"bool":{"must":[{"terms":{"post_type.raw":["post"]}},{"terms":{"post_status":["publish"]}}]}}}' 'http://localhost:9200/mywebsite-post-1/_search'

    > Query Response Code: HTTP 200

    > Here’s a simplified Query Result:

    {
        "took": 33,
        "timed_out": false,
        "_shards": {
            "total": 5,
            "successful": 5,
            "skipped": 0,
            "failed": 0
        },
        "hits": {
            "total": {
                "value": 26,
                "relation": "eq"
            },
            "max_score": null,
            "hits": [
                {
                    "_index": "mywebsite-post-1",
                    "_type": "_doc",
                    "_id": "132",
                    "_score": null,
                    "_source": {
                        "post_id": 132,
                        "ID": 132,
                        ... other fields related to the current hit.
                    },
                    "sort": [
                        1592590310000
                    ]
                },
                {
                    "_index": "mywebsite-post-1",
                    "_type": "_doc",
                    "_id": "133",
                    "_score": null,
                    "_source": {
                        "post_id": 133,
                        "ID": 133,
                        ... other fields related to the current hit.
                    },
                    "sort": [
                        1592590168000
                    ]
                },
    
                ... other hits
            ]
        }
    }

    I don’t know how to instruct ElastiPress to sort by relevancy in order to have related posts.`

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.