Package com.dotcms.repackage.org.elasticsearch.search

Examples of com.dotcms.repackage.org.elasticsearch.search.SearchHits


    int maxIndex = displayPerPage * pageNumber;

    int limit = 0;

    List<Map> l = new ArrayList<Map>();
    SearchHits hits = null;
    List<Contentlet> c = new ArrayList<Contentlet>();

    try {
        c = APILocator.getContentletAPI().search(query, limit, -1, sortBy, user, true);

View Full Code Here


        QueryBuilder builder = QueryBuilders.matchAllQuery();

        SearchResponse response = client.getClient().prepareSearch()
                .setQuery( builder ).addFields("inode","identifier")
                .setSize( limit ).setFrom( offset ).execute().actionGet();
        SearchHits hits = response.getHits();
        List<Contentlet> cons = new ArrayList<Contentlet>();

        for ( SearchHit hit : hits ) {
            try {
                cons.add( find( hit.field("inode").getValue().toString() ) );
View Full Code Here

      SearchRequestBuilder request = createRequest(client, sw.toString());

      IndiciesInfo info=APILocator.getIndiciesAPI().loadIndicies();
      SearchResponse response = request.setIndices((live ? info.live : info.working))
              .addFields("inode","identifier").execute().actionGet();
      SearchHits hits = response.getHits();
      Contentlet contentlet = find(hits.getAt(0).field("inode").getValue().toString());
      return contentlet;
    }
    // if we don't have the con in this language
    catch(java.lang.ArrayIndexOutOfBoundsException aibex){
      return null;
View Full Code Here

      SearchResponse response = createRequest(client.getClient(), "+conhost:"+hostId).
              setSize(limit).setFrom(offset).addFields("inode","identifier").execute()
          .actionGet();

      SearchHits hits = response.getHits();

      List<Contentlet> cons = new ArrayList<Contentlet>();
      for (int i = 0; i < hits.getHits().length; i++) {
        try {
          cons.add(find(hits.getAt(i).field("inode").getValue().toString()));
        } catch (Exception e) {
          throw new ElasticSearchException(e.getMessage(),e);
        }
      }
      return cons;
View Full Code Here

        save(con);
  }

  @Override
  protected List<Contentlet> search(String query, int limit, int offset, String sortBy) throws DotDataException, DotStateException, DotSecurityException {
      SearchHits hits = indexSearch(query, limit, offset, sortBy);
      List<String> inodes=new ArrayList<String>();
      for(SearchHit h : hits)
          inodes.add(h.field("inode").getValue().toString());
      return findContentlets(inodes);
  }
View Full Code Here

    private boolean isDocIndexed ( String id ) {

        if ( !UtilMethods.isSet( id ) ) {
            Logger.warn( this, "Requested Inode is not indexed because Inode is not set" );
        }
        SearchHits lc;
        boolean found = false;
        int counter = 0;
        while ( counter < 300 ) {
            try {
                lc = indexSearch( "+id:" + id, "modDate" );
            } catch ( Exception e ) {
                Logger.error( this.getClass(), e.getMessage(), e );
                return false;
            }
            if ( lc.getTotalHits() > 0 ) {
                found = true;
                return true;
            }
            try {
                Thread.sleep( 100 );
View Full Code Here

            sortBy="random";
        }
        if(limit>MAX_LIMIT || limit <=0){
            limit = MAX_LIMIT;
        }
        SearchHits lc = conFac.indexSearch(buffy.toString(), limit, offset, sortBy);
        PaginatedArrayList <ContentletSearch> list=new PaginatedArrayList<ContentletSearch>();
        list.setTotalResults(lc.getTotalHits());

        for (SearchHit sh : lc.hits()) {
            try{
                Map<String, Object> hm = new HashMap<String, Object>();
                ContentletSearch conwrapper= new ContentletSearch();
                conwrapper.setIdentifier(sh.field("identifier").getValue().toString());
                conwrapper.setInode(sh.field("inode").getValue().toString());
View Full Code Here

    public boolean isInodeIndexed(String inode,boolean live) {
        if(!UtilMethods.isSet(inode)){
            Logger.warn(this, "Requested Inode is not indexed because Inode is not set");
        }
        SearchHits lc;
        boolean found = false;
        int counter = 0;
        while(counter < 300){
            try {
                lc = conFac.indexSearch("+inode:" + inode+(live?" +live:true":""), 0, 0, "modDate");
            } catch (Exception e) {
                Logger.error(this.getClass(),e.getMessage(),e);
                return false;
            }
            if(lc.getTotalHits() > 0){
                found = true;
                return true;
            }
            try{
                Thread.sleep(100);
View Full Code Here

        }
        return found;
    }

    public boolean isInodeIndexed(String inode, int secondsToWait) {
        SearchHits lc;
        boolean found = false;
        int counter = 0;
        while(counter <= (secondsToWait / 10)) {
            try {
                lc = conFac.indexSearch("+inode:" + inode, 0, 0, "modDate");
            } catch (Exception e) {
                Logger.error(this.getClass(),e.getMessage(),e);
                return false;
            }
            if(lc.getTotalHits() > 0){
                found = true;
                return true;
            }
            try{
                Thread.sleep(100);
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.elasticsearch.search.SearchHits

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.