Package com.google.appengine.api.search

Examples of com.google.appengine.api.search.Index


            .addField(Field.newBuilder()
                .setName("published")
                .setDate(model.getPublished())
        ).build();

        Index index = getDocumentIndex(userModel);

        index.put(document);
    }
View Full Code Here


                qstr = qstr + " AND ";
            }
            qstr = qstr + "content:\"" + qstrString[i] + "\"";
        }

        Index index = getDocumentIndex(userModel);


        Query query = Query.newBuilder()
                .setOptions(QueryOptions
                    .newBuilder()
                    .setLimit(100)
                    .setSortOptions(SortOptions.newBuilder()
                    .addSortExpression(SortExpression.newBuilder()
                        .setExpression("published")
                        .setDefaultValueDate(new Date())
                        .setDirection(SortDirection.DESCENDING)))
                    .build()).build(qstr);
        Results<ScoredDocument> results = index.search(query);

        // 対象のアクティビティを取得
        List<ActivityModel> activityList = new ArrayList<ActivityModel>();
        for (ScoredDocument document : results) {
            String activityId = document.getId();
View Full Code Here

        return activityList;
    }

    public static void deleteDocument(UserModel userModel, ActivityModel model) {
        try {
            Index index = getDocumentIndex(userModel);
            index.delete(model.getKey().getName());
        } catch (Exception e) {
        }
    }
View Full Code Here

    if (isFollowed) {
      builder.addField(Field.newBuilder().setName(IS_FIELD).setAtom(IS_FOLLOWED_ATOM));
    }
    Document doc = builder.build();

    Index idx = getIndex(user);

    log.info("Saving index document  " + describe(doc));

    // TODO(danilatos): Factor out all the error handling?
    AddResponse resp;
    try {
      resp = idx.add(doc);
    } catch (AddException e) {
      throw new RetryableFailure("Error indexing " + fields.slobId, e);
    }
    for (OperationResult result : resp) {
      if (!result.getCode().equals(StatusCode.OK)) {
View Full Code Here

  private void initIndex() {
    if (initedIndex) {
      return;
    }
    Index index1 = getArticleIndex();

    for (Article article : articleDao.findAll()) {
      index1.put(createDocument(article));
    }

    Index index2 = getBlogIndex();

    for (Blog blog : blogDao.findAll()) {
      index2.put(createDocument(blog));
    }

    initedIndex = true;
  }
View Full Code Here

    initedIndex = true;
  }

  public void addArticle(Article article) {
    initIndex();
    Index index = getArticleIndex();
    index.put(createDocument(article));
  }
View Full Code Here

    index.put(createDocument(article));
  }

  public void addBlog(Blog blog) {
    initIndex();
    Index index = getBlogIndex();
    index.put(createDocument(blog));
  }
View Full Code Here

    index.put(createDocument(blog));
  }

  public void removeArticle(Long articleId) {
    initIndex();
    Index index = getArticleIndex();
    index.delete(String.valueOf(articleId));
  }
View Full Code Here

    index.delete(String.valueOf(articleId));
  }

  public void removeBlog(Long blogId) {
    initIndex();
    Index index = getBlogIndex();
    index.delete(String.valueOf(blogId));
  }
View Full Code Here

    index.delete(String.valueOf(blogId));
  }

  public List<Article> searchArticles(String query) {
    initIndex();
    Index index = getArticleIndex();

    Results<ScoredDocument> indexResult = index.search(query);

    List<Article> articles = new ArrayList<Article>();
    for (ScoredDocument doc : indexResult) {
      Long articleKey = Long.valueOf(doc.getId());
      articles.add(articleDao.get(articleKey));
View Full Code Here

TOP

Related Classes of com.google.appengine.api.search.Index

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.