기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
NeptuneSearchStep
을 사용하면 Neptune 단계로 변환되지 않는 Gremlin 순회 부분에 대한 전체 텍스트 검색 쿼리를 사용할 수 있습니다. 예를 들어 다음과 같은 쿼리를 고려해 보십시오.
g.withSideEffect("Neptune#fts.endpoint", "
your-es-endpoint-URL
") .V() .tail(100) .has("name", "Neptune#fts mark*") <== # Limit the search on name
이 쿼리는 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} } }]
다음은 air-routes 데이터에 대한 Gremlin 쿼리의 예입니다.
대소문자 구분하지 않는 Gremlin basic match
쿼리
g.withSideEffect("Neptune#fts.endpoint", "
your-OpenSearch-endpoint-URL
") .withSideEffect('Neptune#fts.queryType', 'match') .V().has("city","Neptune#fts dallas") ==>v[186] ==>v[8]
Gremlin match
쿼리
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]
Gremlin fuzzy
쿼리
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
Gremlin query_string
fuzzy 쿼리
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 query_string
정규식 쿼리
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
Gremlin hybrid 쿼리
이 쿼리는 동일한 쿼리에서 Neptune 내부 인덱스와 OpenSearch 인덱스를 사용합니다.
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
간단한 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]
query_string
과 '+' 및 '-' 연산자를 사용하는 Gremlin 쿼리
query_string
쿼리 유형은 기본 simple_query_string
유형보다 훨씬 엄격하지만 보다 정확한 쿼리가 가능합니다. 아래의 첫 번째 쿼리는 query_string
을 사용하고, 두 번째 쿼리는 기본값인 simple_query_string
을 사용합니다.
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]
아래 예제의 simple_query_string
이 어떻게 '+'및 '-'연산자를 자동으로 무시하는지 살펴보십시오.
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]
AND
및 OR
연산자를 사용하는 Gremlin query_string
쿼리
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]
Gremlin term
쿼리
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]
Gremlin prefix
쿼리
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]
Neptune Gremlin에서 Lucene 구문 사용
Neptune Gremlin에서는 Lucene 쿼리 구문을 사용하여 매우 강력한 쿼리를 작성할 수도 있습니다. Lucene 구문은 OpenSearch의 query_string
쿼리에만 지원됩니다.
다음 데이터를 가정합니다.
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")
queryType
이 query_string
일 때 호출되는 Lucene 구문을 사용하여 다음과 같이 이름과 성으로 이 데이터를 검색할 수 있습니다.
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]
위의 has()
단계에서 이 필드는 "*"
로 대체됩니다. 실제로 거기에 배치된 모든 값은 쿼리 내에서 액세스하는 필드에 의해 재정의됩니다. predicates.name.value,
를 사용하여 이름 필드에 액세스할 수 있습니다. 이것이 바로 이 데이터 모델을 구성하는 방법이기 때문입니다.
다음과 같이 이름, 성 및 레이블로 검색할 수 있습니다.
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]
레이블은 데이터 모델이 구조화되는 방식이므로 entity_type
를 사용하여 액세스됩니다.
중첩 조건을 포함할 수도 있습니다.
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]
최신 TinkerPop 그래프 삽입
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')
문자열 필드별 정렬 값 예
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')
비문자열 필드별 정렬 값 예
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')
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')
레이블 필드별 정렬 값 예
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')
document_type
필드별 정렬 값 예
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')