Spring Elasticsearch,创建一个应用趋势请求

huangapple 未分类评论74阅读模式
英文:

Spring Elasticsearch, create a apps trending request

问题

在我的 Elasticsearch 中,我有一个包含应用程序和游戏类别以及大量元数据的 APK 列表。
我必须按类别返回热门交易 APK 的列表。我的请求必须考虑并按照以下最佳组合进行排序:

  1. 当前周内下载最多的 APK(应用程序或游戏)
  2. 评价最积极的
  3. 评论最多的

请问如何创建这种类型的请求?
我使用的是 Spring 2.2 和 Spring Elasticsearch 3.2.4。

@Data
@NoArgsConstructor
@ToString
@Document(indexName = "apk")
public class Apk {

	@Id // 唯一标识符
	private Long id;

	@Field(type = FieldType.Nested, includeInParent = true)
	private Rating rating = new Rating();

	@Field(type = FieldType.Nested, includeInParent = true)
	private List<Review> userReview = new ArrayList<>();

	@Field(type = FieldType.Nested, includeInParent = true)
	private Category category;

	@Field(type = FieldType.Nested, includeInParent = true)
	private SubCategory subCategory;

	private ApkStatus status = ApkStatus.INITIATED;

	private Set<String> dependencies = new HashSet<>();

	private Set<String> permissions = new HashSet<>();
	private String changes;
	private Long companyId;
	private String description;
	private String displayName;

	private String packageName = "unknown";
	private BigDecimal price = new BigDecimal(0);
	private String shortDescription;
	private String versionName = "unknown";
	private String videoUrl;
	private Boolean containsAds;
	private Boolean isFree = false;
	private long versionCode = 0;
	private String minSdkVersion;
	private String targetSdkVersion;
	private String maxSdkVersion;
	private long installs;
	private long unInstalls;
	private long size;
	private String apkName;
	private String repositoryGeneratedId;

	private String iconPath;

	private String iconDownloadUrl;

	private String apkPath;

	private String apkDownloadUrl;

	private String installHistoryString;
	private String unInstallHistoryString;

	@Transient
	private NavigableMap<String, Integer> installHistory = new TreeMap<>();
	@Transient
	private NavigableMap<String, Integer> unInstallHistory = new TreeMap<>();

	private Map<String, TranslatedMetadata> translatedMetadataList = new TreeMap<>();

	LocalizedLanguage defaultLanguage;

	private Date updateDate = new Date();
	private Date createDate = new Date();
}

提前感谢您的帮助。

英文:

In my elasticsearch, I have list of apk with category apps and games and a lot of metadata.
I have to return the list of top trading apk by category. My request must take into account and sort by best combination of:

  1. Most downloaded apk (apps or games) in the current week
  2. Most positively rated
  3. Most commented

How could I do this kind of request please ?
I use spring 2.2 and spring elastic search 3.2.4.

@Data
@NoArgsConstructor
@ToString
@Document(indexName = &quot;apk&quot;)
public class Apk {

	@Id //The unique id
	private Long id;

	@Field(type = FieldType.Nested, includeInParent = true)
	private Rating rating = new Rating();

	@Field(type = FieldType.Nested, includeInParent = true)
	private List&lt;Review&gt; userReview = new ArrayList&lt;&gt;();

	@Field(type = FieldType.Nested, includeInParent = true)
	private Category category;

	@Field(type = FieldType.Nested, includeInParent = true)
	private SubCategory subCategory;

	private ApkStatus status = ApkStatus.INITIATED;

	private Set&lt;String&gt; dependencies = new HashSet&lt;&gt;();

	private Set&lt;String&gt; permissions = new HashSet&lt;&gt;();
	private String changes;
	private Long companyId;
	private String description;
	private String displayName;

	private String packageName = &quot;unknown&quot;;
	private BigDecimal price = new BigDecimal(0);
	private String shortDescription;
	private String versionName = &quot;unknown&quot;;
	private String videoUrl;
	private Boolean containsAds;
	private Boolean isFree=false;
	private long versionCode = 0;
	private String minSdkVersion;
	private String targetSdkVersion;
	private String maxSdkVersion;
	private long installs;
	private long unInstalls;
	private long size;
	private String apkName;
	private String repositoryGeneratedId;

	private String iconPath;  

	private String iconDownloadUrl;
	
	private String apkPath;  

	private String apkDownloadUrl;

	private String installHistoryString;
	private String unInstallHistoryString;
	
	@Transient
	private NavigableMap&lt;String, Integer&gt; installHistory = new TreeMap&lt;&gt;();
	@Transient
	private NavigableMap&lt;String, Integer&gt; unInstallHistory = new TreeMap&lt;&gt;();

	private Map&lt;String, TranslatedMetadata&gt; translatedMetadataList = new TreeMap&lt;&gt;();
	
	LocalizedLanguage defaultLanguage;
	
	private Date updateDate = new Date();
	private Date createDate = new Date();

Thanks in advance

huangapple
  • 本文由 发表于 2020年8月14日 21:28:14
  • 转载请务必保留本文链接:https://java.coder-hub.com/63413722.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定