Java Code Examples for com.google.appengine.api.search.ScoredDocument#getId()

The following examples show how to use com.google.appengine.api.search.ScoredDocument#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchServiceTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void  testGetField() {
    String namelist = "geofield; textfield; numfield; atomfield; datefield; htmlfield; mixfield";
    Results<ScoredDocument> result = searchDocs(index, "", 0);
    for (ScoredDocument doc : result) {
        assertEquals(2, doc.getFieldCount("textfield"));
        String id = doc.getId();
        assertNotNull(id);
        if (id.endsWith("0")) {
            assertEquals(new Locale("cn"), doc.getLocale());
        } else {
            assertEquals(new Locale("en"), doc.getLocale());
        }

        for (String name : doc.getFieldNames()) {
            assertTrue(namelist.contains(name));
        }

        Iterator<Field> fields = doc.getFields().iterator();
        int count = 0;
        for ( ; fields.hasNext() ; ++count ) {
            fields.next();
        }
        assertEquals(9, count);
    }
}
 
Example 2
Source File: SearchServiceTest.java    From appengine-tck with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocale() {
    Results<ScoredDocument> result = searchDocs(index, "", 0);
    for (ScoredDocument doc : result) {
        String id = doc.getId();
        if (id.endsWith("0")) {
            assertEquals(new Locale("cn"), doc.getLocale());
        } else {
            assertEquals(new Locale("en"), doc.getLocale());
        }

        boolean found = false;
        for (Field textField : doc.getFields("textfield")) {
            Locale locale = textField.getLocale();
            if ((locale != null) && locale.equals(Locale.FRENCH)) {
                found = true;
            }
        }
        assertTrue(found);
    }
}