Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.dotmarketing.business.DotStateException;
import com.dotmarketing.business.Role;
import com.dotmarketing.common.model.ContentletSearch;
import com.dotmarketing.common.model.ImmutableContentletSearch;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
Expand Down Expand Up @@ -75,9 +76,9 @@ public ESSearchResults esSearch(String esQuery, boolean live, User user, boolean
for (SearchHit sh : contents.getHits()) {
try {
Map<String, Object> sourceMap = sh.getSourceAsMap();
ContentletSearch conwrapper = new ContentletSearch();
conwrapper.setInode(sourceMap.get("inode").toString());
list.add(conwrapper);
list.add(ImmutableContentletSearch.builder()
.inode(sourceMap.get("inode").toString())
.build());
} catch (Exception e) {
Logger.error(this, e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import com.dotmarketing.cache.FieldsCache;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.common.model.ContentletSearch;
import com.dotmarketing.common.model.ImmutableContentletSearch;
import com.dotmarketing.common.reindex.ReindexQueueAPI;
import com.dotmarketing.comparators.ContentMapComparator;
import com.dotmarketing.db.DbConnectionFactory;
Expand Down Expand Up @@ -1685,14 +1686,13 @@ public List<ContentletSearch> searchIndex(String luceneQuery, int limit, int off
for (final com.dotcms.content.index.domain.SearchHit searchHit : searchHits.hits()) {
try {
final Map<String, Object> sourceMap = searchHit.sourceAsMap();
final ContentletSearch conWrapper = new ContentletSearch();
conWrapper.setId(searchHit.id());
conWrapper.setIndex(searchHit.index());
conWrapper.setIdentifier(sourceMap.get("identifier").toString());
conWrapper.setInode(sourceMap.get("inode").toString());
conWrapper.setScore(searchHit.score());

list.add(conWrapper);
list.add(ImmutableContentletSearch.builder()
.id(searchHit.id())
.index(searchHit.index())
.identifier(sourceMap.get("identifier").toString())
.inode(sourceMap.get("inode").toString())
.score(searchHit.score())
.build());
} catch (Exception e) {
Logger.error(this, e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dotcms.content.index.domain.SearchHit;
import com.dotcms.content.index.domain.SearchHits;
import com.dotmarketing.common.model.ContentletSearch;
import com.dotmarketing.common.model.ImmutableContentletSearch;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotRuntimeException;
import com.dotmarketing.util.Config;
Expand Down Expand Up @@ -196,14 +197,13 @@ private List<ContentletSearch> getContentletSearchFromSearchHits(final SearchHit
for (SearchHit sh : searchHits.hits()) {
try{
Map<String, Object> sourceMap = sh.sourceAsMap();
ContentletSearch conwrapper= new ContentletSearch();
conwrapper.setId(sh.id());
conwrapper.setIndex(sh.index());
conwrapper.setIdentifier(sourceMap.get("identifier").toString());
conwrapper.setInode(sourceMap.get("inode").toString());
conwrapper.setScore(sh.score());

list.add(conwrapper);
list.add(ImmutableContentletSearch.builder()
.id(sh.id())
.index(sh.index())
.identifier(sourceMap.get("identifier").toString())
.inode(sourceMap.get("inode").toString())
.score(sh.score())
.build());
}
catch(Exception e){
Logger.error(this,e.getMessage(),e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dotcms.content.index.domain.SearchHit;
import com.dotcms.content.index.domain.SearchHits;
import com.dotmarketing.common.model.ContentletSearch;
import com.dotmarketing.common.model.ImmutableContentletSearch;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotRuntimeException;
import com.dotcms.content.index.IndexConfigHelper;
Expand Down Expand Up @@ -237,14 +238,13 @@ private List<ContentletSearch> getContentletSearchFromSearchHits(final SearchHit
for (SearchHit sh : searchHits.hits()) {
try {
Map<String, Object> sourceMap = sh.sourceAsMap();
ContentletSearch conwrapper = new ContentletSearch();
conwrapper.setId(sh.id());
conwrapper.setIndex(sh.index());
conwrapper.setIdentifier(sourceMap.get("identifier").toString());
conwrapper.setInode(sourceMap.get("inode").toString());
conwrapper.setScore(sh.score());

list.add(conwrapper);
list.add(ImmutableContentletSearch.builder()
.id(sh.id())
.index(sh.index())
.identifier(sourceMap.get("identifier").toString())
.inode(sourceMap.get("inode").toString())
.score(sh.score())
.build());
} catch (Exception e) {
Logger.error(this, e.getMessage(), e);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.web.WebAPILocator;
import com.dotmarketing.common.model.ContentletSearch;
import com.dotmarketing.common.model.ImmutableContentletSearch;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotRuntimeException;
import com.dotmarketing.exception.DotSecurityException;
Expand Down Expand Up @@ -410,10 +411,10 @@ public static List<ContentletSearch> query(String query, int limit, String sort,
List<Contentlet> conts=pull(query, limit, sort, user, tmDate);
ret = new ArrayList<>(conts.size());
for(Contentlet cm : conts) {
ContentletSearch cs=new ContentletSearch();
cs.setInode((String)cm.get("inode"));
cs.setIdentifier((String)cm.get("identifier"));
ret.add(cs);
ret.add(ImmutableContentletSearch.builder()
.inode((String) cm.get("inode"))
.identifier((String) cm.get("identifier"))
.build());
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,25 @@
package com.dotmarketing.common.model;


public class ContentletSearch {
private String id;
private String inode;
private String identifier;
private String index;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getIndex() {
return index;
}
public void setIndex(String index) {
this.index = index;
}
float score;
public float getScore() {
return score;
}
public void setScore(float score) {
this.score = score;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getIdentifier() {
return identifier;
}
public void setInode(String inode) {
this.inode = inode;
}
public String getInode() {
return inode;
}
@Override
public String toString() {
return "ContentletSearch [id=" + id + ", inode=" + inode + ", identifier=" + identifier + ", index=" + index + ", score=" + score
+ "]";
}




}
package com.dotmarketing.common.model;

import javax.annotation.Nullable;
import org.immutables.value.Value;

@Value.Immutable
public interface ContentletSearch {

@Nullable
String getId();

@Nullable
String getInode();

@Nullable
String getIdentifier();

@Nullable
String getIndex();

@Value.Default
default float getScore() {
return 0.0f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.dotmarketing.beans.Host;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.common.model.ContentletSearch;
import com.dotmarketing.common.model.ImmutableContentletSearch;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.contentlet.business.ContentletAPI;
Expand Down Expand Up @@ -295,9 +296,9 @@ public void getContentletWithReallyPaginationAndMock()
}

private ContentletSearch createContentletSearch(Contentlet contentlet1) {
final ContentletSearch contentletSearch_1 = new ContentletSearch();
contentletSearch_1.setInode(contentlet1.getInode());
return contentletSearch_1;
return ImmutableContentletSearch.builder()
.inode(contentlet1.getInode())
.build();
}

@Test
Expand Down
Loading