Menggunakan pencarian teks lengkap Neptune dalam kueri Gremlin - Amazon Neptune

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Menggunakan pencarian teks lengkap Neptune dalam kueri Gremlin

NeptuneSearchStep memungkinkan kueri pencarian teks lengkap untuk bagian dari traversal Gremlin yang tidak diubah menjadi langkah-langkah Neptune. Contohnya, pertimbangkan kueri berikut ini.

g.withSideEffect("Neptune#fts.endpoint", "your-es-endpoint-URL") .V() .tail(100) .has("name", "Neptune#fts mark*") <== # Limit the search on name

Kueri ini diubah menjadi traversal yang dioptimalkan berikut di Neptune.

Neptune steps: [ NeptuneGraphQueryStep(Vertex) { JoinGroupNode { PatternNode[(?1, <~label>, ?2, <~>) . project distinct ?1 .], {estimatedCardinality=INFINITY} }, annotations={path=[Vertex(?1):GraphStep], maxVarId=4} }, NeptuneTraverserConverterStep ] + not converted into Neptune steps: [NeptuneTailGlobalStep(100), NeptuneTinkerpopTraverserConverterStep, NeptuneSearchStep { JoinGroupNode { SearchNode[(idVar=?3, query=mark*, field=name) . project ask .], {endpoint=your-OpenSearch-endpoint-URL} } JoinGroupNode { SearchNode[(idVar=?3, query=mark*, field=name) . project ask .], {endpoint=your-OpenSearch-endpoint-URL} } }]

Contoh berikut adalah dari kueri Gremlin terhadap data rute udara:

matchKueri case-sensitif dasar Gremlin

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'match') .V().has("city","Neptune#fts dallas") ==>v[186] ==>v[8]

matchKueri Gremlin

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'match') .V().has("city","Neptune#fts southampton") .local(values('code','city').fold()) .limit(5) ==>[SOU, Southampton]

fuzzyKueri Gremlin

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .V().has("city","Neptune#fts allas~").values('city').limit(5) ==>Dallas ==>Dallas ==>Walla Walla ==>Velas ==>Altai

Gremlinquery_string fuzzy query

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .V().has("city","Neptune#fts allas~").values('city').limit(5) ==>Dallas ==>Dallas

Gremlin permintaan ekspresiquery_string reguler

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .V().has("city","Neptune#fts /[dp]allas/").values('city').limit(5) ==>Dallas ==>Dallas

Kueri Hybrid Gremlin

Kueri ini menggunakan indeks internal Neptune dan OpenSearch indeks dalam kueri yang sama.

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .V().has("region","GB-ENG") .has('city','Neptune#fts L*') .values('city') .dedup() .limit(10) ==>London ==>Leeds ==>Liverpool ==>Land's End

Contoh pencarian teks lengkap Gremlin

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .V().has('desc','Neptune#fts regional municipal') .local(values('code','desc').fold()) .limit(100) ==>[HYA, Barnstable Municipal Boardman Polando Field] ==>[SPS, Sheppard Air Force Base-Wichita Falls Municipal Airport] ==>[ABR, Aberdeen Regional Airport] ==>[SLK, Adirondack Regional Airport] ==>[BFD, Bradford Regional Airport] ==>[EAR, Kearney Regional Airport] ==>[ROT, Rotorua Regional Airport] ==>[YHD, Dryden Regional Airport] ==>[TEX, Telluride Regional Airport] ==>[WOL, Illawarra Regional Airport] ==>[TUP, Tupelo Regional Airport] ==>[COU, Columbia Regional Airport] ==>[MHK, Manhattan Regional Airport] ==>[BJI, Bemidji Regional Airport] ==>[HAS, Hail Regional Airport] ==>[ALO, Waterloo Regional Airport] ==>[SHV, Shreveport Regional Airport] ==>[ABI, Abilene Regional Airport] ==>[GIZ, Jizan Regional Airport] ==>[USA, Concord Regional Airport] ==>[JMS, Jamestown Regional Airport] ==>[COS, City of Colorado Springs Municipal Airport] ==>[PKB, Mid Ohio Valley Regional Airport]

Kueri Gremlin menggunakanquery_string Operator '+' dan '-' dan '-' dan '-' dan '-' dan '-'

Meskipun jenis kueri query_string jauh lebih pemaaf dari jenis simple_query_string default, kueri tersebut memungkinkan kueri yang lebih tepat. Kueri pertama di bawah ini menggunakan query_string, sedangkan yang kedua menggunakan simple_query_string default:

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') . V().has('desc','Neptune#fts +London -(Stansted|Gatwick)') .local(values('code','desc').fold()) .limit(10) ==>[LHR, London Heathrow] ==>[YXU, London Airport] ==>[LTN, London Luton Airport] ==>[SEN, London Southend Airport] ==>[LCY, London City Airport]

Perhatikan bagaimana simple_query_string dalam contoh di bawah diam-diam mengabaikan operator '+' dan '-':

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .V().has('desc','Neptune#fts +London -(Stansted|Gatwick)') .local(values('code','desc').fold()) .limit(10) ==>[LHR, London Heathrow] ==>[YXU, London Airport] ==>[LGW, London Gatwick] ==>[STN, London Stansted Airport] ==>[LTN, London Luton Airport] ==>[SEN, London Southend Airport] ==>[LCY, London City Airport] ==>[SKG, Thessaloniki Macedonia International Airport] ==>[ADB, Adnan Menderes International Airport] ==>[BTV, Burlington International Airport]
g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .V().has('desc','Neptune#fts +(regional|municipal) -(international|bradford)') .local(values('code','desc').fold()) .limit(10) ==>[CZH, Corozal Municipal Airport] ==>[MMU, Morristown Municipal Airport] ==>[YBR, Brandon Municipal Airport] ==>[RDD, Redding Municipal Airport] ==>[VIS, Visalia Municipal Airport] ==>[AIA, Alliance Municipal Airport] ==>[CDR, Chadron Municipal Airport] ==>[CVN, Clovis Municipal Airport] ==>[SDY, Sidney Richland Municipal Airport] ==>[SGU, St George Municipal Airport]

Gremlinquery_string query denganAND danOR operator

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .V().has('desc','Neptune#fts (St AND George) OR (St AND Augustin)') .local(values('code','desc').fold()) .limit(10) ==>[YIF, St Augustin Airport] ==>[STG, St George Airport] ==>[SGO, St George Airport] ==>[SGU, St George Municipal Airport]

termKueri Gremlin

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'term') .V().has("SKU","Neptune#fts ABC123DEF9") .local(values('code','city').fold()) .limit(5) ==>[AUS, Austin]

prefixKueri Gremlin

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'prefix') .V().has("icao","Neptune#fts ka") .local(values('code','icao','city').fold()) .limit(5) ==>[AZO, KAZO, Kalamazoo] ==>[APN, KAPN, Alpena] ==>[ACK, KACK, Nantucket] ==>[ALO, KALO, Waterloo] ==>[ABI, KABI, Abilene]

Menggunakan sintaks Lucene di Neplin

Di Neptune Gremlin, Anda juga dapat menulis kueri yang sangat kuat menggunakan sintaks kueri Lucene. Perhatikan bahwa sintaks Lucene hanya didukung untukquery_string query di OpenSearch.

Asumsikan data berikut:

g.addV("person") .property(T.id, "p1") .property("name", "simone") .property("surname", "rondelli") g.addV("person") .property(T.id, "p2") .property("name", "simone") .property("surname", "sengupta") g.addV("developer") .property(T.id, "p3") .property("name", "simone") .property("surname", "rondelli")

Menggunakan sintaks Lucene, yang dipanggil ketika queryType adalah query_string, Anda dapat mencari data ini menurut nama dan nama keluarga sebagai berikut:

g.withSideEffect("Neptune#fts.endpoint", "es_endpoint") .withSideEffect("Neptune#fts.queryType", "query_string") .V() .has("*", "Neptune#fts predicates.name.value:simone AND predicates.surname.value:rondelli") ==> v[p1], v[p3]

Perhatikan bahwa dalam langkah has() di atas, bidangnya digantikan oleh "*"). Sebenarnya, setiap nilai yang ditempatkan di bidang tersebut diganti oleh bidang yang Anda akses dalam kueri. Anda mengakses bidang nama menggunakan predicates.name.value, karena itulah cara model data terstruktur.

Anda dapat mencari berdasarkan nama, nama keluarga, dan label, sebagai berikut:

g.withSideEffect("Neptune#fts.endpoint", getEsEndpoint()) .withSideEffect("Neptune#fts.queryType", "query_string") .V() .has("*", "Neptune#fts predicates.name.value:simone AND predicates.surname.value:rondelli AND entity_type:person") ==> v[p1]

Label diakses menggunakan entity_type, sekali lagi karena itulah cara model data terstruktur.

Anda juga bisa memasukkan syarat nesting:

g.withSideEffect("Neptune#fts.endpoint", getEsEndpoint()) .withSideEffect("Neptune#fts.queryType", "query_string") .V() .has("*", "Neptune#fts (predicates.name.value:simone AND predicates.surname.value:rondelli AND entity_type:person) OR predicates.surname.value:sengupta") ==> v[p1], v[p2]

Memasukkan TinkerPop grafik modern

g.addV('person').property(T.id, '1').property('name', 'marko').property('age', 29) .addV('personr').property(T.id, '2').property('name', 'vadas').property('age', 27) .addV('software').property(T.id, '3').property('name', 'lop').property('lang', 'java') .addV('person').property(T.id, '4').property('name', 'josh').property('age', 32) .addV('software').property(T.id, '5').property('name', 'ripple').property('lang', 'java') .addV('person').property(T.id, '6').property('name', 'peter').property('age', 35) g.V('1').as('a').V('2').as('b').addE('knows').from('a').to('b').property('weight', 0.5f).property(T.id, '7') .V('1').as('a').V('3').as('b').addE('created').from('a').to('b').property('weight', 0.4f).property(T.id, '9') .V('4').as('a').V('3').as('b').addE('created').from('a').to('b').property('weight', 0.4f).property(T.id, '11') .V('4').as('a').V('5').as('b').addE('created').from('a').to('b').property('weight', 1.0f).property(T.id, '10') .V('6').as('a').V('3').as('b').addE('created').from('a').to('b').property('weight', 0.2f).property(T.id, '12') .V('1').as('a').V('4').as('b').addE('knows').from('a').to('b').property('weight', 1.0f).property(T.id, '8')

Urutkan berdasarkan contoh nilai bidang string

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .withSideEffect('Neptune#fts.sortOrder', 'asc') .withSideEffect('Neptune#fts.sortBy', 'name') .V().has('name', 'Neptune#fts marko OR vadas OR ripple')

Urutkan berdasarkan contoh nilai bidang non-string

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .withSideEffect('Neptune#fts.sortOrder', 'asc') .withSideEffect('Neptune#fts.sortBy', 'age.value') .V().has('name', 'Neptune#fts marko OR vadas OR ripple')

Urutkan berdasarkan contoh nilai bidang ID

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .withSideEffect('Neptune#fts.sortOrder', 'asc') .withSideEffect('Neptune#fts.sortBy', 'Neptune#fts.entity_id') .V().has('name', 'Neptune#fts marko OR vadas OR ripple')

Urutkan berdasarkan contoh nilai bidang label

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .withSideEffect('Neptune#fts.sortOrder', 'asc') .withSideEffect('Neptune#fts.sortBy', 'Neptune#fts.entity_type') .V().has('name', 'Neptune#fts marko OR vadas OR ripple')

Urutkan berdasarkan contoh nilaidocument_type bidang

g.withSideEffect("Neptune#fts.endpoint", "your-OpenSearch-endpoint-URL") .withSideEffect('Neptune#fts.queryType', 'query_string') .withSideEffect('Neptune#fts.sortOrder', 'asc') .withSideEffect('Neptune#fts.sortBy', 'Neptune#fts.document_type') .V().has('name', 'Neptune#fts marko OR vadas OR ripple')