Bonjour, j'ai actuellement le filtre / code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 @Transactional(propagation = Propagation.REQUIRED) public List<IJob> getJobListForZipCode(long functionId, long parution, String filter, String[] typeId, String zipCode, String typeZoom) { List<IJob> jobs = new ArrayList<IJob>(); List<IJob> tempJobs = null; long today = new Date().getTime(); FullTextEntityManager fem = Search.getFullTextEntityManager(em); Analyzer analyzer = fem.getSearchFactory().getAnalyzer( SOLR_JOB_ANALYZER_NAME); MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[] { "name", "description" }, analyzer); DecimalFormat nfId = new DecimalFormat("000", DecimalFormatSymbols .getInstance(Locale.US)); if (filter != null && !"".equals(filter.trim()) && (!filter.startsWith("ent:"))) { try { parser.setAllowLeadingWildcard(true); // Lucene parser don't want this char if (filter != null) { filter = filter.replace(':', ' ').trim(); filter = filter.replace('^', ' ').trim(); } Query query = parser.parse(StringUtils.convertNonAscii(filter)); FullTextQuery hibQuery = fem.createFullTextQuery(query, JobEntity.class); for(int d=0 ; d < typeId.length ; d++ ){ hibQuery.enableFullTextFilter("JobEntity.filter.geoZipCode") .setParameter("publicationDelay", parution) .setParameter("functionId", nfId.format(functionId)); //.setParameter("typeId", nfId.format(Long.parseLong(typeId[d]))) //.setParameter("zipCode", zipCode); tempJobs = (List<IJob>) hibQuery.getResultList(); } List<Long> companyIdWithoutSubscriptionList = em .createQuery( "select distinct c.id from CompanyEntity c " + "where (c.id in (select s.company.id from SubscriptionEntity s " + "where s.startDate <= " + today + " and " + today + " <= s.endDate)) ") .getResultList(); Map<Long, Object> companyIdWithoutSubscriptionMap = returnCompanyIdWithoutSubscription(companyIdWithoutSubscriptionList); Iterator it = tempJobs.iterator(); while (it.hasNext()) { IJob tempJob = (IJob) it.next(); if (companyIdWithoutSubscriptionMap .containsKey((Long) tempJob.getCompany().getId())) { jobs.add(tempJob); } } } catch (ParseException e) { e.printStackTrace(); jobs = new ArrayList<IJob>(); } } return jobs; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { long functionId = computeFunctionIdParameters(request); long parution = computeParutionParameter(request); String filter = computeFilterParameter(request); String[] typeId = computeTypeIdParameter(request); String[] zipCode = zipCodeParameter(request); String typeZoom = ""; putZoomParameterInSession(request); WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); facade =(IBusinessClientFacade)springContext.getBean("facade"); List<List<IJob>> jobs = new ArrayList<List<IJob>>(); if(zipCode.length < 23){ typeZoom = "Region"; } else{ typeZoom = "Departement"; } if (filter != null && !"".equals(filter.trim()) && (!filter.startsWith("ent:"))) { jobs.add(facade.getJobListForZipCode(functionId, parution, filter, typeId, zipCode[0],typeZoom)); } else{ for(int i = 0, l = zipCode.length; i < l; i++){ jobs.add(facade.getJobListForZipCode(functionId, parution, filter, typeId, zipCode[i],typeZoom)); } } response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); PrintWriter pw = response.getWriter(); pw.print(JSONUtils.JSONJobs(zipCode,jobs)); pw.close(); response.flushBuffer(); }Ce code / filtre existait deja avant, mais sans les parametres TypeId et ZipCode, et je tente donc de le modifier afin qu'il prenne en compte ces parametres , ce que , jusqu'a present je n'arrive pas à faire.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public class GeoZipFilter { private long publicationDelay; private String functionId; private String typeId; private String zipCode; @Key public FilterKey getKey() { StandardFilterKey key = new StandardFilterKey(); key.addParameter(publicationDelay); key.addParameter(functionId); key.addParameter(typeId); key.addParameter(zipCode); return key; } @Factory public Filter getFilter() { ChainedFilter filter = new ChainedFilter() { /** * */ private static final long serialVersionUID = 8725514094671660409L; public BitSet bits(IndexReader reader) throws IOException { return super.bits(reader); } }; filter.addFilter(new RangeFilter("publicationDate", String.valueOf(System.currentTimeMillis()-publicationDelay) , String.valueOf(System.currentTimeMillis()), true, true)); if (!functionId.equals("000")) { filter.addFilter(new RangeFilter("functionId", functionId, functionId, true, true)); } /* if (!typeId.equals("000")) { filter.addFilter(new RangeFilter("typeId", typeId, typeId, true, true)); } if (!zipCode.equals("000")){ filter.addFilter(new RangeFilter("workAddress.zipCode", zipCode+"000" , zipCode+"999" , true, false)); } */ filter.addFilter(new RangeFilter("archivingDate","0","0",true,true)); return new CachingWrapperFilter(filter) { private static final long serialVersionUID = 4491361196544402881L; @SuppressWarnings("deprecation") public BitSet bits(IndexReader reader) throws IOException { return super.bits(reader); } }; }
Là ils sont commentés , mais si je les active dans mon code, le resultat de ma requete est null
SI par hasard, une bonne âme connaissant le FullTextSearch passait par là :p
merci.
Partager