Phoenixsearch เป็นเครื่องมือค้นหาแบบเรียลไทม์แบบเต็มเวลาที่รวดเร็วและทันสมัยโดยใช้ Redis + Php7


composer create-project phoenixsearch/phoenixsearch yourprojectpath/จากนั้นซีดีไปยัง ProjectPath ของคุณ/ และรัน:
php phoenixsearchd.php < key > กุญแจสำคัญอยู่ในไฟล์ .env ของคุณ
PS คุณต้องการ phoenixsearchd เพื่อดำเนินงานที่ซับซ้อนมาเป็นเวลานานเช่นการลบดัชนีทั้งหมดข้อมูล Reindex ไปยังดัชนี/indexType อื่น
เป็นไปได้ที่จะระบุกระบวนการตามชื่อ:
ps aux | grep phoenixsearch จัดทำดัชนีเอกสารใหม่ลงในที่เก็บข้อมูลและเพิ่มขึ้น docs_count ในข้อมูลดัชนี
ขอ:
PUT http://pheonixsearch.loc/myindex/myindextype?pretty {
"title" : " Lorem ipsum is a pseudo-Latin text " ,
"text" : " Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philosopher Cicero. Its words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Latin, it actually has no meaning whatsoever. As Cicero's text doesn't contain the letters K, W, or Z, alien to latin, these, and others are often inserted randomly to mimic the typographic appearence of European languages, as are digraphs not to be found in the original. "
}การตอบสนอง:
{
"created" : true ,
"took" : 23 ,
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 2 ,
"result" : " created " ,
"_version" : 1
} หากการอัปเดตที่มีเนื้อหาเดียวกันเกิดขึ้นเอกสารนี้จะพบได้และคุณสมบัติ _version จะได้รับการอัปเดตเป็น i++
ขอ:
PUT http://pheonixsearch.loc/myindex/myindextype?pretty {
"title" : " Lorem ipsum is a pseudo-Latin text " ,
"text" : " Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philosopher Cicero. Its words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Latin, it actually has no meaning whatsoever. As Cicero's text doesn't contain the letters K, W, or Z, alien to latin, these, and others are often inserted randomly to mimic the typographic appearence of European languages, as are digraphs not to be found in the original. "
}การตอบสนอง:
{
"created" : false ,
"took" : 1 ,
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 1 ,
"result" : " updated " ,
"_version" : 2
} ไม่ว่าคุณจะต้องค้นหาตามคำหรือวลีเพียงเพิ่ม query->term ในร่างกาย JSON
ขอ:
GET http://pheonixsearch.loc/myindex/myindextype?pretty {
"query" : {
"term" : { "title" : " Lorem ipsum " }
}
}การตอบสนอง:
{
"took" : 1 ,
"timed_out" : false ,
"hits" : {
"total" : 2 ,
"hits" : [
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 1 ,
"_timestamp" : 1502997604 ,
"_source" : {
"title" : " Lorem ipsum is a pseudo-Latin text " ,
"text" : " Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philosopher Cicero. Its words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Latin, it actually has no meaning whatsoever. As Cicero's text doesn't contain the letters K, W, or Z, alien to latin, these, and others are often inserted randomly to mimic the typographic appearence of European languages, as are digraphs not to be found in the original. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 2 ,
"_timestamp" : 1502997883 ,
"_source" : {
"title" : " Lorem ipsum is a pseudo-Latin text used in web design " ,
"text" : " Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philosopher Cicero. Its words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Latin, it actually has no meaning whatsoever. As Cicero's text doesn't contain the letters K, W, or Z, alien to latin, these, and others are often inserted randomly to mimic the typographic appearence of European languages, as are digraphs not to be found in the original. "
}
}
]
}
}โดยการชดเชยคำขอค้นหา (เช่นใน SQL) คุณพูดกับเอ็นจิ้น - เริ่มรวบรวมเอกสารจาก J สำหรับจำนวน K หากตั้งค่าขีด จำกัด
ขอ:
GET http://pheonixsearch.loc/myindex/myindextype?pretty {
"offset" : 10 ,
"limit" : 5 ,
"query" : {
"term" : { "text" : " quis " }
}
}การตอบสนอง:
{
"took" : 11 ,
"timed_out" : false ,
"hits" : {
"total" : 5 ,
"hits" : [
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 695 ,
"_timestamp" : 1503231848 ,
"_source" : {
"title" : " Ms. " ,
"text" : " Et aut et dolor assumenda ea. Iste corrupti quis quis voluptas similique quos tenetur. Et nisi dolore quod quidem architecto qui. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 2027 ,
"_timestamp" : 1503231889 ,
"_source" : {
"title" : " Dr. " ,
"text" : " Quae ut ad omnis est. Impedit reiciendis illo aut magnam fugit. Sed ratione illum quibusdam illum et dolores quis quia. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 4506 ,
"_timestamp" : 1503232042 ,
"_source" : {
"title" : " Dr. " ,
"text" : " Necessitatibus quod est commodi accusamus. Occaecati quis nam veritatis quia. Dicta a non ex non repellendus sed ipsa. Molestiae aliquam quia dolor porro laboriosam corporis consequatur. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 4568 ,
"_timestamp" : 1503232046 ,
"_source" : {
"title" : " Dr. " ,
"text" : " Magnam quis nihil aliquid nihil enim. Ad id odio tenetur aut. Nihil ea iusto aliquam ut. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 7398 ,
"_timestamp" : 1503232264 ,
"_source" : {
"title" : " Mrs. " ,
"text" : " Non adipisci sunt quisquam sint ullam qui sed. Ut voluptate eum quia quia. Nihil blanditiis eos quis fuga unde reprehenderit veritatis voluptatem. Dolorum neque temporibus vel reiciendis voluptatem. "
}
}
]
}
} เมื่อคุณต้องการเน้นคำวลี ฯลฯ มันง่ายพอที่จะทำโดยการเพิ่มคุณสมบัติ highlight ลงในโครงการ JSON
{
"offset" : 5 ,
"limit" : 5 ,
"highlight" : {
"pre_tags" : [ " <tag1> " , " <tag2> " ],
"post_tags" : [ " </tag1> " , " </tag2> " ],
"fields" : {
"name" : {}, "text" : {}
}
},
"query" : {
"term" : { "text" : " quis enim " }
}
}{
"took" : 46 ,
"timed_out" : false ,
"hits" : {
"total" : 5 ,
"hits" : [
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : " 7483 " ,
"_timestamp" : " 1503232272 " ,
"_source" : {
"title" : " Dr. " ,
"text" : " Pariatur aut consequatur cumque dolores. Hic quis tempora quia error suscipit <tag1><tag2>quis enim</tag1></tag2> omnis. Et ut aperiam voluptatum officia rem vitae quod. Cupiditate qui et commodi est quod. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : " 3973 " ,
"_timestamp" : " 1503232006 " ,
"_source" : {
"title" : " Prof. " ,
"text" : " Corporis provident tempore omnis voluptatem voluptates distinctio aliquam voluptatem. Non quis <tag1><tag2>quis enim</tag1></tag2> nulla aliquid quidem eligendi. Rerum et mollitia consequuntur consequatur. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : " 3276 " ,
"_timestamp" : " 1503231961 " ,
"_source" : {
"title" : " Miss " ,
"text" : " Distinctio voluptatem autem exercitationem quo cumque. Labore omnis sapiente qui itaque. Sunt iusto et porro id <tag1><tag2>quis enim</tag1></tag2> corrupti. Quaerat id doloribus est adipisci et debitis voluptas. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : " 3827 " ,
"_timestamp" : " 1503231997 " ,
"_source" : {
"title" : " Dr. " ,
"text" : " Iure est culpa vitae blanditiis explicabo voluptatem aliquam. Nostrum ullam quo ipsum reprehenderit magni officiis dolor. Quo <tag1><tag2>quis enim</tag1></tag2> facilis quidem facilis quaerat. "
}
},
{
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : " 9524 " ,
"_timestamp" : " 1503232463 " ,
"_source" : {
"title" : " Miss " ,
"text" : " Nam dolorem et laboriosam <tag1><tag2>quis enim</tag1></tag2> voluptas. Rerum vel nihil delectus fugit qui. Tempore quis commodi error provident aperiam esse. Dolorum nulla ipsa molestias veritatis dolorem sed distinctio. "
}
}
]
}
}ลบเอกสารหนึ่งฉบับโดย IT ของ IT, ลดลงเคาน์เตอร์ในข้อมูลดัชนีโดย 1
DELETE http://pheonixsearch.loc/myindex/myindextype/2?prettyสำหรับเอกสารที่มีอยู่จะส่งคืน:
{
"found" : true ,
"took" : 6 ,
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 2 ,
"result" : " deleted " ,
"_version" : 1
}สำหรับเอกสารที่ไม่มีอยู่จริง:
{
"found" : false ,
"took" : 1 ,
"_index" : " myindex " ,
"_type" : " myindextype " ,
"_id" : 2 ,
"result" : " not found " ,
"_version" : 1
}ลบข้อมูลดัชนีทั้งหมดออกจากที่เก็บข้อมูล
DELETE http://pheonixsearch.loc/myindex/myindextypeการตอบสนอง:
{
"acknowledged" : true
} ข้อความ "acknowledged": true หมายถึงงานถูกประมวลผลภายใต้ Daemon phoenixsearchd
สำเนาเอกสารจากดัชนีหนึ่งไปยังอีกอันหนึ่งด้วยการแมปของดัชนีต้นทางโดยค่าเริ่มต้น
POST http://pheonixsearch.loc/_reindex {
"source" : {
"index" : " myindex " ,
"index_type" : " myindextype "
},
"dest" : {
"index" : " myanotherindex " ,
"index_type" : " myanothertype "
}
}การตอบสนอง:
{
"acknowledged" : true
}คำขอนี้จะส่งออกข้อมูลทั่วไปเกี่ยวกับดัชนีทั้งหมดที่เก็บไว้
GET http://pheonixsearch.loc/_cat/indices [
{
"store_size" : " 456.91M "
},
{
"_index" : " myanotherindex " ,
"docs_count" : 2 ,
"docs_deleted" : 0
},
{
"_index" : " myindex " ,
"docs_count" : 12687 ,
"docs_deleted" : 1
}
] store_size เป็นขนาดของที่เก็บข้อมูลสำหรับดัชนีทั้งหมดที่ได้รับจาก Redis
GET http://pheonixsearch.loc/myindex {
"myindex" : {
"aliases" : [],
"mappings" : {
"myindextype" : {
"properties" : {
"title" : {
"type" : " text " ,
"fields" : {
"whitespace" : {
"type" : " whitespace " ,
"ignore_above" : 0
}
}
},
"text" : {
"type" : " text " ,
"fields" : {
"whitespace" : {
"type" : " whitespace " ,
"ignore_above" : 0
}
}
},
"data" : {
"type" : " text " ,
"fields" : {
"whitespace" : {
"type" : " whitespace " ,
"ignore_above" : 0
}
}
}
}
}
}
}
} "ignore_above": 0 หมายถึงไม่มีการ จำกัด ความยาวสตริง (ข้อความ) ประเภท whitespace เป็นประเภทเริ่มต้นของเครื่องวิเคราะห์ดัชนีกลับด้านซึ่งเพิ่งทำลายข้อความโดยโทเค็น Whitespace
ขอ:
{
"offset" : 5 ,
"limit" : 10 ,
"highlight" : {
"pre_tags" : [ " <tag1> " , " <tag2> " ],
"post_tags" : [ " </tag1> " , " </tag2> " ],
"fields" : {
"name" : {}, "text" : {}
}
},
"query" : {
"term" : { "text" : " quis enim " }
}
}
การตอบสนอง:
{
"took" : 57 ,
"timed_out" : false ,
"hits" : {
"total" : 10 ... ขอ:
{
"offset" : 5 ,
"limit" : 10 ,
"query" : {
"term" : { "text" : " quis enim " }
}
}การตอบสนอง:
{
"took" : 34 ,
"timed_out" : false ,
"hits" : {
"total" : 10 ... ขอ:
{
"query" : {
"term" : { "text" : " quis enim " }
}
}การตอบสนอง:
{
"took" : 72 ,
"timed_out" : false ,
"hits" : {
"total" : 229 ... ขอ:
{
"query" : {
"term" : { "text" : " quis " }
}
}การตอบสนอง:
{
"took" : 49 ,
"timed_out" : false ,
"hits" : {
"total" : 2450 ...อย่างที่คุณเห็นการเลือกนั้นเร็วอย่างไม่น่าเชื่อไม่มีเวทมนตร์ - เพียงแค่ Redis กับ C เป็น Core
ขอ:
{
"title" : " Lorem ipsum is a pseudo-Latin text used in web design " ,
"text" : " Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philosopher Cicero. Its words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Latin, it actually has no meaning whatsoever. As Cicero's text doesn't contain the letters K, W, or Z, alien to latin, these, and others are often inserted randomly to mimic the typographic appearence of European languages, as are digraphs not to be found in the original. " ,
"data" : " 2017-08-21 "
}การตอบสนอง:
{
"created" : true ,
"took" : 66 ...
}ขอ:
http://pheonixsearch.loc/myindex/myindextype/44972?prettyการตอบสนอง:
{
"found" : true ,
"took" : 33 ...took เวลาวัดเป็นมิลลิวินาที