วัตถุประสงค์ของฟังก์ชันเพิ่มโซลอร์

ฉันเจอชุดโค้ดเดิมซึ่งมีการตั้งค่าตัวแปรไดนามิกบางตัวเป็นฟังก์ชัน solr boost

String query = "{!boost b=sum(" + searchQuery.getFieldsToBoost() + ")}";

การดำเนินการนี้จะหยุดพักในกรณีที่ searchQuery.getFieldsToBoost() มีเครื่องหมายวรรคตอนใดๆ เหล่านี้ + - && || ! ( ) { } [ ] ^ " ~ * ? : \

ดังนั้นฉันจึงพยายามหลีกเลี่ยงตัวอักษรพิเศษเหล่านี้ในฟังก์ชัน boost sum() โดยใช้แนวทางที่ให้ไว้ใน https://lucene.apache.org/core/2_9_4/queryparsersyntax.html

แต่วิธีการข้างต้นไม่ได้ผล

ต่อไปนี้เป็นข้อผิดพลาด:

Caused by: org.apache.lucene.queryParser.ParseException: Expected ',' at position 631 in 'sum(itemAttributes_A3,itemAttributes_ASD,itemAttributes_ASD1,itemAttributes_Bang,itemAttributes_Color,itemAttributes_ES,itemAttributes_El_Segundo_only,itemAttributes_Environment_Friendly,itemAttributes_MossPoint_only,itemAttributes_NAUFIL,itemAttributes_NorthDakota_only,itemAttributes_Off_Contract,itemAttributes_On_Contract,itemAttributes_PBINFO,itemAttributes_PPD,itemAttributes_Palmdale_only,itemAttributes_Preferred,itemAttributes_Punchout,itemAttributes_RanchoBernardo_only,itemAttributes_SEARCHABLE,itemAttributes_Services,itemAttributes_SpacePark_only,itemAttributes_custom_flag12,itemAttributes_FL_01,itemAttributes_hyphen\-field,itemAttributes_icon,itemAttributes_required_PPD,itemAttributes_semicolon;field,itemAttributes_space_field,attributes_Green_certified,attributes_Preferred_contract,attributes_Service_Disabled_Veteran,attributes_Veteran_Owned,attributes_Minority_Owned,attributes_Woman_Owned,attributes_Hubzone,attributes_Tier_II_Contract,attributes_Red_Attribute)'

ดังนั้นฉันจึงคิดที่จะแทนที่อักขระพิเศษทั้งหมดใน searchQuery.getFieldsToBoost() เพื่อขีดเส้นใต้

แต่ฉันไม่รู้ว่ามันจะส่งผลต่อผลการค้นหา / บูสต์ผลลัพธ์อย่างไร

โดยพื้นฐานแล้วจะดีมากถ้ามีใครสามารถช่วยฉันในการหลบหนีตัวอักษรพิเศษหรือให้ภาพรวมของผลสะท้อนกลับหลังจากแทนที่อักขระพิเศษเป็นขีดเส้นใต้

ฉันไม่เข้าใจว่าจุดประสงค์ของการเพิ่มโซลคืออะไร


person Niranjan Kumar    schedule 04.01.2017    source แหล่งที่มา
comment
คุณช่วยแสดงสิ่งที่ getFieldsToBoost ส่งคืนได้ไหม   -  person Mysterion    schedule 09.01.2017
comment
โดยจะส่งกลับสตริงที่คั่นด้วยเครื่องหมายจุลภาคในรูปแบบ itemAttributes_{Dynamic_FieldName} เมื่อ {Dynamic_FieldName} นี้ประกอบด้วยอักขระพิเศษที่ระบุข้างต้น อักขระนั้นจะหยุดทำงาน   -  person Niranjan Kumar    schedule 10.01.2017
comment
ถ้าคุณไม่ได้รับสิ่งที่กำลังส่งเสริม ทำไมคุณถึงใช้มัน?   -  person Mysterion    schedule 10.01.2017
comment
ฟังก์ชั่นบูสต์มีแนวโน้มที่จะเปลี่ยนผลการค้นหาด้วยหรือไม่ คุณช่วยอธิบายได้ไหมว่าทำไมมันถึงใช้โดยทั่วไป?   -  person Niranjan Kumar    schedule 10.01.2017


คำตอบ (1)


วัตถุประสงค์ของฟังก์ชันส่งเสริมคือเพื่อเพิ่มเงื่อนไขหรือเอกสารหรือฟิลด์เฉพาะเมื่อส่งคืนผลลัพธ์ จะไม่เพิ่มหรือเปลี่ยนแปลงชุดผลลัพธ์ เช่น มันสามารถเปลี่ยนลำดับได้เท่านั้น

ตัวอย่างเช่น หากคุณตัดสินใจว่าฟิลด์ ชื่อ มีความสำคัญมากกว่า คำอธิบาย คุณสามารถตั้งค่าด้วยการเพิ่มประสิทธิภาพได้ เช่นเดียวกัน หากคุณตัดสินใจว่าคำว่า Nike นั้นสำคัญกว่าคำว่า Adidas

ข้อมูลเพิ่มเติมบางส่วนที่นี่

person Mysterion    schedule 10.01.2017