Skip to content

Instantly share code, notes, and snippets.

@arofiqimaulana
Created May 2, 2025 03:41
Show Gist options
  • Select an option

  • Save arofiqimaulana/8771142a63968f884bbd73985cc73cf9 to your computer and use it in GitHub Desktop.

Select an option

Save arofiqimaulana/8771142a63968f884bbd73985cc73cf9 to your computer and use it in GitHub Desktop.
Contoh elastic kedua
{
"size": 10,
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "kopi manis",
"fields": [
"deskripsi^3", // Boost 3 untuk deskripsi
"bentuk^2", // Boost 2 untuk bentuk
"warna^2" // Boost 2 untuk warna
],
"type": "most_fields", // Pencarian ini akan mempertimbangkan semua field yang ada dalam query
"minimum_should_match": "2" // Minimal dua kata dalam query harus cocok
}
},
{
"match_phrase": {
"bentuk": {
"query": "kopi",
"slop": 2, // Fleksibilitas dua kata antar kata untuk pencocokan frasa
"boost": 3 // Meningkatkan skor jika cocok di bentuk
}
}
},
{
"match_phrase": {
"warna": {
"query": "coklat",
"slop": 2, // Fleksibilitas dua kata antar kata
"boost": 2 // Meningkatkan skor jika cocok di warna
}
}
}
],
"minimum_should_match": 1 // Minimal satu kondisi dari 'should' harus cocok
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment