Hi All!
I am fairly new in the world of ElasticSearch, and using it in a very basic way.
I would like to use Elastic in a more complex way, but i can't get it to work in the way i would like.
At this moment we have our own MySQL search engine which is slow...
It is used to search trough products and give a score for every kind of match that is found.
- match in title is 1 points,
 - match in brandname is an extra 2 points,
 - match in product-category name is 1 extra point,
 - etc.
 
I would like to create this method with Elastic, but i can not get it to use a fixed score for multiple fields.
I did some experiments with BOOL queries with a constant_score. When i searched one field the score did match the 'boost' value, but when searched multiple fields, the score result wasn't a rounded number. For example, i want every product with "cooler" in the name, and give it an extra score when "cooler" is also in the brand name:
{
	"query": {
		"bool": {
			"should": [
			{
				"constant_score": {
					"boost": 1,
					filter: {
						"wildcard": {
							"naam": "*cooler*"
						}
					}
				}
			},
			{
				"constant_score": {
					"boost": 2,
					filter: {
						"wildcard": {
							"merk": "*cooler*"
						}
					}
				}
			}
			]
		}
	},
    "size": 100
}
This results in scores like 1.3416407, where i expect a 3.0 score:
{
    "took": 47,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 599,
        "max_score": 1.3416407,
        "hits": [
            {
                "_index": "products",
                "_type": "product",
                "_id": "153136",
                "_score": 1.3416407,
                "_source": {
                    "artikelnr": 153136,
                    "naam": "Cooler Master Jetflo blauwe led, 120mm",
                    "prodgroep": 10,
                    "subgroep": 11,
                    "groepnaam": "Koeling (lucht)",
                    "subgroepnaam": "Case fan 120mm",
                    "merk": "Cooler Master",
                    "vendor": "R4-JFDP-20PB-R1",
                    "ean": "4719512042267",
                    "synoniem": [
                        ""
                    ],
                    "synced": "2018-10-10 09:48:01"
                }
            },
            {
                "_index": "products",
                "_type": "product",
                "_id": "995569",
                "_score": 1.3416407,
                "_source": {
                    "artikelnr": 995569,
                    "naam": "Cooler Master MasterLiquid Pro 280",
                    "prodgroep": 42,
                    "subgroep": 8,
                    "groepnaam": "Koeling (water)",
                    "subgroepnaam": "Complete sets CPU",
                    "merk": "Cooler Master",
                    "vendor": "MLY-D28M-A22MB-R1",
                    "ean": "4719512052631",
                    "synoniem": [
                        "Waterkoeling"
                    ],
                    "synced": "2018-10-29 01:37:01"
                }
            },
            {
                "_index": "products",
                "_type": "product",
                "_id": "975619",
                "_score": 1.3416407,
                "_source": {
                    "artikelnr": 975619,
                    "naam": "Cooler Master MasterKeys Pro M (White LED) - Brown Switch",
                    "prodgroep": 15,
                    "subgroep": 1,
                    "groepnaam": "Invoerapparaten",
                    "subgroepnaam": "Toetsenborden",
                    "merk": "Cooler Master",
                    "vendor": "SGK-4080-KKCM1-US",
                    "ean": "4719512052129",
                    "synoniem": [
                        ""
                    ],
                    "synced": "2018-10-30 10:19:01"
                }
            },
--- code limited ---
Is there a way to use the scoring mechanism the way i want?