Last active
July 13, 2020 08:44
-
-
Save javagrails/db97c512c73dfe49914c6bbc5e3cbc69 to your computer and use it in GitHub Desktop.
solr data type field mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://bigwisdom.net/solr-tutorial-learn-solr-in-2-hours/ | |
========================== Solr Basic Data Types for Index ============================= | |
Data Type |Index_Suffix |Example | |
---------------------------------------------------------------------- | |
String _s id:"1051", | |
String _s url_s:"https://javagrails.wordpress.com/", | |
String _s title_s:"MackBookProkk", | |
String _s description_s:"dmlasd", | |
String _s duration_s:"dasdsad", | |
Long _l viewCount_l:2, | |
String _s playlist_s:"hgfghj", | |
String _s documentType_s:"video", | |
String Array/Set/List _ss documentKeywords_ss:["jhjhsd"], | |
String _s parentUrl_s:"https://javagrails.wordpress.com/", | |
String _s sourceUrl_s:"https://javagrails.wordpress.com/", | |
String _s sourceName_s:"sddsf", | |
String _s sourceLogoUrl_s:"https://javagrails.wordpress.com/", | |
String _s sourceWebsite_s:"https://javagrails.wordpress.com/", | |
Long _l score_l:2, | |
String _s imageUrl_s:"https://javagrails.wordpress.com/", | |
String _s language_s:"EN", | |
String _s status_s:"PUBLISHED", | |
Date _dt fetchedDate_dt:"2017-12-31T19:00:00Z", | |
Long _l userId_l:4, | |
String _s userLogin_s:"user", | |
String Array/Set/List _ss categoryNames_ss:["Architecture", "Counseling"], | |
Long Array/Set/List _ls categoryIds_ls:[3, 5], | |
String Array/Set/List _ss authorNames_ss:["Myra Osborn", "Alexa King", "Ann Burnett"], | |
Long Array/Set/List _ls authorIds_ls:[2, 8, 10], | |
========================== The Best System Like Below ============================= | |
(1..5).each { item -> | |
String docId = item.toString() | |
String docTitle = 'Document_title_'+docId | |
String docUrl = 'http://www.open.com/Document_url_'+docId | |
String docDescription = 'Document_description_'+docId | |
String docImageUrl = 'http://placehold.it/50x50' | |
Set<String> docCities = ["Dhaka", "Tangail", "Dhanbari", "Madhupur"] | |
Set<Long> docCityIds = [20, 22, 23, 25] | |
Double docPrice = Math.random()*2.9 | |
Date fetchedDate = new Date().minus(5) | |
Date lastModified = new Date().plus(5) | |
SolrBlogDTO doc = new SolrBlogDTO() | |
doc.setId(docId) | |
doc.setTitle(docTitle) | |
doc.setUrl(docUrl) | |
doc.setDescription(docDescription) | |
doc.setScore(Math.random().longValue()) | |
doc.setImageUrl(docImageUrl) | |
doc.setCities(docCities) | |
doc.setCityIds(docCityIds) | |
doc.setPrice(docPrice) | |
doc.setFetchedDate(fetchedDate) | |
doc.setLastModified(lastModified) | |
println(doc) | |
springBlogService.blogSearchRepository.save(doc) | |
} | |
--------------------------------------------------------------- | |
{ | |
"id":"1", | |
"title_s":"Document_title_1", | |
"url_s":"http://www.open.com/Document_url_1", | |
"description_s":"Document_description_1", | |
"score_l":0, | |
"imageUrl_s":"http://placehold.it/50x50", | |
"cities_ss":["Dhaka", | |
"Tangail", | |
"Dhanbari", | |
"Madhupur"], | |
"cityIds_ls":[20, | |
22, | |
23, | |
25], | |
"price_d":0.7555966879266465, | |
"fetchedDate_dt":"2018-02-10T20:25:53.721Z", | |
"lastModified_dt":"2018-02-20T20:25:53.723Z", | |
"_version_":1592500005318426624 | |
} | |
------------------------------------------------------------ | |
@Id | |
@Field | |
private String id; | |
@Field("title_s") | |
private String title; | |
@Field("url_s") | |
private String url; | |
@Field("description_s") | |
private String description; | |
@Field("score_l") | |
private Long score; | |
@Field("imageUrl_s") | |
private String imageUrl; | |
@Field("cities_ss") | |
private Set<String> cities = new HashSet<>(); | |
@Field("cityIds_ls") | |
private Set<Long> cityIds = new HashSet<>(); | |
@Field("price_d") | |
private Double price; | |
@Field("fetchedDate_dt") | |
private Date fetchedDate; | |
@Field("lastModified_dt") | |
private Date lastModified; | |
============================================================================= | |
{ | |
"id":"9", | |
"title_s":"Document_title_9", | |
"url_text":["http://www.open.com/Document_url_9"], | |
"description_txt":["Document_description_9"], | |
"score_l":0, | |
"imageUrl_t":["http://placehold.it/50x50"], | |
"cities_ss":["Dhaka", | |
"Tangail", | |
"Dhanbari", | |
"Madhupur"], | |
"cityIds_ls":[20, | |
22, | |
23, | |
25], | |
"price_d":1.78524962298035, | |
"fetchedDate_dt":"2018-02-10T20:44:15.757Z", | |
"lastModified_dt":"2018-02-20T20:44:15.757Z", | |
"imageUrl_t_str":["http://placehold.it/50x50"], | |
"url_text_str":["http://www.open.com/Document_url_9"], | |
"_version_":1592501160654143488 | |
} | |
=============================================================================== | |
@Id | |
@Field // solr => "id":"9", | |
private String id; | |
@Field("title_s") // solr => "title_s":"Document_title_9", | |
private String title; | |
@Field("url_text") // solr => "url_text":["http://www.open.com/Document_url_9"], | |
private String url; // solr creates extra filed => "url_text_str":["http://www.open.com/Document_url_9"], | |
@Field("description_txt") // solr => "description_txt":["Document_description_9"], | |
private String description; | |
@Field("score_l") // solr => "score_l":0, | |
private Long score; | |
@Field("imageUrl_t") // solr => "imageUrl_t":["http://placehold.it/50x50"], | |
private String imageUrl; // solr creates extra filed => "imageUrl_t_str":["http://placehold.it/50x50"], | |
@Field("cities_ss") // solr => "cities_ss":["Dhaka", "Tangail", "Dhanbari", "Madhupur"], | |
private Set<String> cities = new HashSet<>(); | |
@Field("cityIds_ls") // solr => "cityIds_ls":[20, 22, 23, 25], | |
private Set<Long> cityIds = new HashSet<>(); | |
@Field("price_d") // solr => "price_d":1.78524962298035, | |
private Double price; | |
@Field("fetchedDate_dt") // solr =>"fetchedDate_dt":"2018-02-10T20:44:15.757Z", | |
private Date fetchedDate; | |
@Field("lastModified_dt") // solr => "lastModified_dt":"2018-02-20T20:44:15.757Z", | |
private Date lastModified; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment