@Test public void testDeleteWithAlias() throws IOException { final String entityType = "thing"; IndexEdge searchEdge = new IndexEdgeImpl( appId, "things", SearchEdge.NodeType.SOURCE, 1 ); final SearchTypes searchTypes = SearchTypes.fromTypes( entityType ); insertJsonBlob( entityType, searchEdge, "/sample-large.json", 1, 0 ); entityIndex.addIndex(UUID.randomUUID() + "v2", 1, 0, "one"); entityIndex.refreshAsync().toBlocking().first(); insertJsonBlob( entityType, searchEdge, "/sample-large.json", 1, 1 ); CandidateResults crs = testQuery( searchEdge, searchTypes, "name = 'Bowers Oneil'", 1 ); EntityIndexBatch entityIndexBatch = entityIndex.createBatch(); entityIndexBatch.deindex(searchEdge, crs.get(0)); indexProducer.put(entityIndexBatch.build()).subscribe(); entityIndex.refreshAsync().toBlocking().first(); //Hilda Youn testQuery(searchEdge, searchTypes, "name = 'Bowers Oneil'", 0); }
logger.debug("Query time {}ms", timer.getTime()); final CandidateResult candidate1 = candidateResults.get(0);
if ( !results.isEmpty() && results.get( 0 ).getId().equals( entityObservable.getId() ) ) { found = true;
@Test public void deleteVerification() throws Throwable { Id ownerId = new SimpleId( "owner" ); IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 ); final String middleName = "middleName" + UUIDUtils.newTimeUUID(); Map entityMap = new HashMap() {{ put( "username", "edanuff" ); put( "email", "ed@anuff.com" ); put( "middlename", middleName ); }}; Entity user = EntityIndexMapUtils.fromMap( entityMap ); EntityUtils.setId( user, new SimpleId( "edanuff" ) ); EntityUtils.setVersion( user, UUIDGenerator.newTimeUUID() ); EntityIndexBatch batch = entityIndex.createBatch(); batch.index( indexSCope, user ); indexProducer.put(batch.build()).subscribe();; entityIndex.refreshAsync().toBlocking().first(); final String query = "where username = 'edanuff'"; CandidateResults r = entityIndex.search( indexSCope, SearchTypes.fromTypes( "edanuff" ), query, 10, 0, false); assertEquals( user.getId(), r.get( 0 ).getId()); batch.deindex( indexSCope, user.getId(), user.getVersion() ); indexProducer.put(batch.build()).subscribe();; entityIndex.refreshAsync().toBlocking().first(); // EntityRef r = entityIndex.search( indexSCope, SearchTypes.fromTypes( "edanuff" ), query, 10, 0, false ); assertFalse( r.iterator().hasNext() ); }
assertEquals(1, results.size()); assertEquals(newVersion, results.get(0).getVersion());
assertEquals(first.getId(), singleResults.get(0).getId()); assertEquals( second.getId(), singleKeywordUnion.get( 0).getId() ); assertEquals( first.getId(), singleKeywordUnion.get( 1 ).getId() ); assertEquals(second.getId(), towMatchResults.get( 0).getId() ); assertEquals(first.getId(), towMatchResults.get( 1 ).getId() );
@Test public void queryByUUID() throws Throwable { Id appId = new SimpleId( "application" ); Id ownerId = new SimpleId( "owner" ); IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 ); final UUID searchUUID = UUIDGenerator.newTimeUUID(); Map entityMap = new HashMap() {{ put( "searchUUID", searchUUID ); }}; Entity user = EntityIndexMapUtils.fromMap( entityMap ); final Id entityId = new SimpleId( "entitytype" ); EntityUtils.setId( user, entityId ); EntityUtils.setVersion( user, UUIDGenerator.newTimeUUID() ); EntityIndexBatch batch = entityIndex.createBatch(); batch.index( indexSCope, user ); indexProducer.put(batch.build()).subscribe();; entityIndex.refreshAsync().toBlocking().first(); final String query = "where searchUUID = " + searchUUID; final CandidateResults r = entityIndex.search( indexSCope, SearchTypes.fromTypes(entityId.getType()), query, 10, 0, false); assertEquals(user.getId(), r.get(0).getId()); }
assertEquals(second.getId(), notFirstResults.get( 0 ).getId() ); assertEquals( first.getId(), notSecondUnion.get( 0 ).getId() ); assertEquals( second.getId(), notBothReturnResults.get( 0).getId() ); assertEquals( first.getId(), notBothReturnResults.get( 1 ).getId() ); assertEquals( second.getId(), noMatchesAndResults.get( 0).getId() ); assertEquals( first.getId(), noMatchesAndResults.get( 1 ).getId() ); assertEquals( second.getId(), noMatchesOrResults.get( 0).getId() ); assertEquals( first.getId(), noMatchesOrResults.get( 1 ).getId() );
@Test public void queryByStringWildCardSpaces() throws Throwable { Id appId = new SimpleId( "application" ); Id ownerId = new SimpleId( "owner" ); IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 ); Map entityMap = new HashMap() {{ put( "string", "I am a search string" ); }}; Entity user = EntityIndexMapUtils.fromMap( entityMap ); final Id entityId = new SimpleId( "entitytype" ); EntityUtils.setId( user, entityId ); EntityUtils.setVersion( user, UUIDGenerator.newTimeUUID() ); EntityIndexBatch batch = entityIndex.createBatch(); batch.index(indexSCope, user); indexProducer.put(batch.build()).subscribe();; entityIndex.refreshAsync().toBlocking().first(); final String query = "where string = 'I am*'"; final CandidateResults r = entityIndex.search( indexSCope, SearchTypes.fromTypes( entityId.getType() ), query, 10, 0, false); assertEquals(user.getId(), r.get(0).getId()); //shouldn't match final String queryNoWildCard = "where string = 'I am'"; final CandidateResults noWildCardResults = entityIndex.search( indexSCope, SearchTypes.fromTypes( entityId.getType() ), queryNoWildCard, 10, 0, false ); assertEquals( 0, noWildCardResults.size() ); }
CandidateResult candidate = candidates.get( consistent ); assertNotNull( candidate );
assertEquals(second.getId(), notFirstResults.get( 0 ).getId() ); assertEquals(second.getId(), notFirstWildCardResults.get( 0 ).getId() ); assertEquals(second.getId(), notFirstContainsResults.get( 0 ).getId() ); assertEquals( first.getId(), notSecondUnion.get( 0 ).getId() ); assertEquals( first.getId(), notSecondWildcardUnion.get( 0 ).getId() ); assertEquals( first.getId(), notSecondContainsUnion.get( 0 ).getId() ); assertEquals( second.getId(), notBothReturnResults.get( 0).getId() ); assertEquals( first.getId(), notBothReturnResults.get( 1 ).getId() );