Examples of FacetQuery


Examples of org.apache.blur.lucene.search.FacetQuery

  private Query getFacetedQuery(BlurQuery blurQuery, Query userQuery, AtomicLongArray counts,
      FieldManager fieldManager, TableContext context, Filter postFilter, Filter preFilter) throws ParseException {
    if (blurQuery.facets == null) {
      return userQuery;
    }
    return new FacetQuery(userQuery, getFacetQueries(blurQuery, fieldManager, context, postFilter, preFilter), counts);
  }
View Full Code Here

Examples of org.apache.blur.lucene.search.FacetQuery

      Query facetedQuery;
      FacetExecutor executor = null;
      if (blurQuery.facets != null) {
        long[] facetMinimums = getFacetMinimums(blurQuery.facets);
        executor = new FacetExecutor(blurQuery.facets.size(), facetMinimums, facetedCounts, running);
        facetedQuery = new FacetQuery(userQuery, getFacetQueries(blurQuery, fieldManager, context, rowFilterForSearch,
            recordFilterForSearch), executor);
      } else {
        facetedQuery = userQuery;
      }
View Full Code Here

Examples of org.fluxtream.core.services.ApiDataService.FacetQuery

            // mymeeId is unique for each observation
            final String mymeeId = observation.getString("_id");

            MymeeObservationFacet ret = (MymeeObservationFacet)
                    apiDataService.createOrReadModifyWrite(MymeeObservationFacet.class,
                                                           new FacetQuery(
                                                                   "e.apiKeyId = ? AND e.mymeeId = ?",
                                                                   updateInfo.apiKey.getId(),
                                                                   mymeeId),
                                                           new FacetModifier<MymeeObservationFacet>() {
                        // Throw exception if it turns out we can't make sense of the observation's JSON
View Full Code Here

Examples of org.fluxtream.core.services.ApiDataService.FacetQuery

            smsBackupAddress = message.getHeader("X-backup2gmail-sms-address")[0];
        }
        final String emailId = messageId + smsBackupId;
        if (type == SmsEntryFacet.class){
            return apiDataService.createOrReadModifyWrite(SmsEntryFacet.class,
                                                   new FacetQuery(
                                                           "e.apiKeyId = ? AND e.emailId = ?",
                                                           updateInfo.apiKey.getId(),
                                                           emailId),
                                                   new FacetModifier<SmsEntryFacet>() {
                                                       // Throw exception if it turns out we can't make sense of the observation's JSON
                                                       // This will abort the transaction
                                                       @Override
                                                       public SmsEntryFacet createOrModify(SmsEntryFacet facet, Long apiKeyId) {
                                                           if (facet == null) {
                                                               facet = new SmsEntryFacet(updateInfo.apiKey.getId());
                                                               facet.emailId = emailId;
                                                               facet.guestId = updateInfo.apiKey.getGuestId();
                                                               facet.api = updateInfo.apiKey.getConnector().value();
                                                           }

                                                           facet.timeUpdated = System.currentTimeMillis();

                                                           try{
                                                               InternetAddress[] senders = null;
                                                               try{
                                                                   senders =  (InternetAddress[]) message.getFrom();
                                                               } catch (AddressException ignored){}
                                                               InternetAddress[] recipients = null;
                                                               try{
                                                                   recipients =  (InternetAddress[]) message.getRecipients(MimeMessage.RecipientType.TO);
                                                               } catch (AddressException ignored){}
                                                               String fromAddress, toAddress;
                                                               boolean senderMissing = false, recipientsMissing = false;
                                                               if (senders != null && senders.length > 0){
                                                                   fromAddress = senders[0].getAddress();
                                                               }
                                                               else{
                                                                   fromAddress = message.getSubject().substring(9);
                                                                   senderMissing = true;
                                                               }
                                                               if (recipients != null && recipients.length > 0){
                                                                   toAddress =  recipients[0].getAddress();
                                                               }
                                                               else{
                                                                   toAddress = message.getSubject().substring(9);
                                                                   recipientsMissing = true;
                                                               }
                                                               if (fromAddress.startsWith(username)) {
                                                                   facet.smsType = SmsEntryFacet.SmsType.OUTGOING;
                                                                   if (recipientsMissing){
                                                                       facet.personName = toAddress;
                                                                       facet.personNumber = smsBackupAddress;
                                                                   }
                                                                   else if (toAddress.indexOf("unknown.email")!=-1) {
                                                                       facet.personName = recipients[0].getPersonal();
                                                                       facet.personNumber = toAddress.substring(0, toAddress.indexOf("@"));
                                                                   }
                                                                   else {
                                                                       facet.personName = recipients[0].getPersonal();
                                                                       facet.personNumber = smsBackupAddress;
                                                                   }
                                                               }else {
                                                                   facet.smsType = SmsEntryFacet.SmsType.INCOMING;
                                                                   if (senderMissing){
                                                                       facet.personName = fromAddress;
                                                                       facet.personNumber = smsBackupAddress;
                                                                   }
                                                                   else if (fromAddress.indexOf("unknown.email")!=-1) {
                                                                       facet.personName = senders[0].getPersonal();
                                                                       facet.personNumber = fromAddress.substring(0, fromAddress.indexOf("@"));
                                                                   }
                                                                   else {
                                                                       facet.personName = senders[0].getPersonal();
                                                                       facet.personNumber = smsBackupAddress;
                                                                   }
                                                               }
                                                               facet.dateReceived = message.getSentDate();
                                                               facet.start = facet.dateReceived.getTime();
                                                               facet.end = facet.start;
                                                               Object content = message.getContent();
                                                               facet.hasAttachments = false;
                                                               if (content instanceof String)
                                                                   facet.message = (String) message.getContent();
                                                               else if (content instanceof MimeMultipart) {//TODO: this is an MMS and needs to be handled properly
                                                                   facet.message = "";
                                                                   MimeMultipart multipart = (MimeMultipart) content;
                                                                   int partCount = multipart.getCount();
                                                                   for (int i = 0; i < partCount; i++){
                                                                       MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(i);
                                                                       String contentType = part.getContentType().split(";")[0].toLowerCase();
                                                                       Object partContent = part.getContent();
                                                                       if (contentType.startsWith("text/plain")){//other types of text are returned as byte streams and are attachments
                                                                            if (!facet.message.equals("")){
                                                                                facet.message += "\n\n";
                                                                            }
                                                                           facet.message = (String) partContent;
                                                                       }
                                                                       else{
                                                                           if (!facet.hasAttachments){
                                                                               facet.hasAttachments = true;
                                                                               facet.attachmentMimeTypes = contentType;
                                                                               facet.attachmentNames = (emailId + i).replaceAll("\\W+","");
                                                                           }
                                                                           else{
                                                                               facet.attachmentMimeTypes += "," + contentType;
                                                                               facet.attachmentNames += "," + (emailId + i).replaceAll("\\W+","");

                                                                           }

                                                                           File attachmentFile = getAttachmentFile(env.targetEnvironmentProps.getString("btdatastore.db.location"),updateInfo.getGuestId(),updateInfo.apiKey.getId(),(emailId + i).replaceAll("\\W+",""));
                                                                           attachmentFile.getParentFile().mkdirs();
                                                                           FileOutputStream fileoutput = new FileOutputStream(attachmentFile);
                                                                           IOUtils.copy((BASE64DecoderStream) partContent, fileoutput);
                                                                           fileoutput.close();
                                                                       }
                                                                   }
                                                               }
                                                           }  catch(Exception e){
                                                               e.printStackTrace();
                                                               return null;
                                                           }
                                                           return facet;
                                                       }
                                                   }, updateInfo.apiKey.getId());

        }
        else if (type == CallLogEntryFacet.class){
            return apiDataService.createOrReadModifyWrite(CallLogEntryFacet.class,
                                                   new FacetQuery(
                                                           "e.apiKeyId = ? AND e.emailId = ?",
                                                           updateInfo.apiKey.getId(),
                                                           emailId),
                                                   new FacetModifier<CallLogEntryFacet>() {
                                                       // Throw exception if it turns out we can't make sense of the observation's JSON
View Full Code Here

Examples of org.springframework.data.solr.core.query.FacetQuery

    return getSolrOperations().queryForPage(query, Product.class);
  }

  @Override
  public FacetPage<Product> findByNameStartingWithAndFacetOnAvailable(String namePrefix) {
    FacetQuery query = new SimpleFacetQuery(new Criteria(SolrSearchableFields.NAME).startsWith(namePrefix));
    query.setFacetOptions(new FacetOptions(SolrSearchableFields.AVAILABLE));
    return getSolrOperations().queryForFacetPage(query, Product.class);
  }
View Full Code Here

Examples of org.springframework.data.solr.core.query.FacetQuery

    if (solrQueryMethod.isPageQuery() || solrQueryMethod.isSliceQuery()) {
      if (solrQueryMethod.isFacetQuery() && solrQueryMethod.isHighlightQuery()) {
        throw new InvalidDataAccessApiUsageException("Facet and Highlight cannot be combined.");
      }
      if (solrQueryMethod.isFacetQuery()) {
        FacetQuery facetQuery = SimpleFacetQuery.fromQuery(query, new SimpleFacetQuery());
        facetQuery.setFacetOptions(extractFacetOptions(solrQueryMethod, accessor));
        return new FacetPageExecution(accessor.getPageable()).execute(facetQuery);
      }
      if (solrQueryMethod.isHighlightQuery()) {
        HighlightQuery highlightQuery = SimpleHighlightQuery.fromQuery(query, new SimpleHighlightQuery());
        highlightQuery.setHighlightOptions(extractHighlightOptions(solrQueryMethod, accessor));
View Full Code Here

Examples of org.springframework.data.solr.core.query.FacetQuery

      values.add(createExampleBeanWithId(Integer.toString(i)));
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnField("name").addFacetOnField("id").setFacetLimit(5));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);

    for (Page<FacetFieldEntry> facetResultPage : page.getFacetResultPages()) {
View Full Code Here

Examples of org.springframework.data.solr.core.query.FacetQuery

      values.add(createExampleBeanWithId(Integer.toString(i)));
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnPivot("cat", "name"));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);

    List<FacetPivotFieldEntry> pivotEntries = page.getPivot("cat,name");
View Full Code Here

Examples of org.springframework.data.solr.core.query.FacetQuery

      values.add(bean);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new SimpleStringCriteria("*:*"));
    q.setFacetOptions(new FacetOptions(new SimpleQuery(new SimpleStringCriteria("inStock:true")), new SimpleQuery(
        new SimpleStringCriteria("inStock:false"))));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);

    Page<FacetQueryEntry> facetQueryResultPage = page.getFacetQueryResult();
View Full Code Here

Examples of org.springframework.data.solr.core.query.FacetQuery

    ExampleSolrBean language = new ExampleSolrBean("4", "java", "language");

    solrTemplate.saveBeans(Arrays.asList(season, framework, island, language));
    solrTemplate.commit();

    FacetQuery q = new SimpleFacetQuery(new Criteria(Criteria.WILDCARD).expression(Criteria.WILDCARD))
        .setFacetOptions(new FacetOptions().addFacetOnField("name").setFacetLimit(5).setFacetPrefix("spr"));

    FacetPage<ExampleSolrBean> page = solrTemplate.queryForFacetPage(q, ExampleSolrBean.class);
    Page<FacetFieldEntry> facetPage = page.getFacetResultPage(new SimpleField("name"));
    for (FacetFieldEntry entry : facetPage) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.