You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Cant find specific record in search sosl query
Hello, I created a searchbar component to show records that include at least one field with the input. The problem i have is, that
When I insert 'Ar' it should find the records that have 'arbeitgeber' in the field Zielgruppe, bc it contains 'Ar'.
Unfortunatly I dont find the Record 'Equal Pension, even tough it contains Ar in the field Zielgruppe.
Could you look over my code and give me an advice what to change so the problem does not occure
When I insert 'Ar' it should find the records that have 'arbeitgeber' in the field Zielgruppe, bc it contains 'Ar'.
Unfortunatly I dont find the Record 'Equal Pension, even tough it contains Ar in the field Zielgruppe.
Could you look over my code and give me an advice what to change so the problem does not occure
public with sharing class MediathekSearchController { @AuraEnabled(cacheable=true) public static List<sObject> getSearchResult(String searchKey, String TypValue, String ZielgruppeValue, String ThemaValue){ String findStr = ' '+searchKey+' '; Boolean isEmptySearch = String.isEmpty(searchKey); system.debug('searchKey ' + searchKey); system.debug('findStr ' + findStr); system.debug('KategorieValue' + TypValue); system.debug('ZielgruppeValue' + ZielgruppeValue); system.debug('ThemaValue' + ThemaValue); List<List<sObject>> searchResult; if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Mediathek_ID_Long__c, Thema__c, ContentDocumentID__c, ContentVersionId__c, Thumbnail_Image__c,Thumbnail_Preview2__c, Name, Bezeichnung__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c Where Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Thumbnail_Image__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, Typ__c, ContentDocumentID__c, Thumbnail_Image__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Inaktiv__c=false)]; } else if(ThemaValue == 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue == 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, Typ__c, ContentDocumentID__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue == 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Name, Mediathek_ID_Long__c, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Inaktiv__c=false)]; } else if(ThemaValue != 'Alle' && ZielgruppeValue != 'Alle' && TypValue != 'Alle'){ searchResult = [FIND :findStr IN ALL FIELDS RETURNING Mediathek__c (Id, Thema__c, Mediathek_ID_Long__c, Name, Bezeichnung__c, ContentDocumentID__c, Typ__c, Zielgruppe__c, Umfang__c, Bezeichnung_Link__c, Bezeichnung_Search__c WHERE Thema__c=:ThemaValue AND Typ__c=:TypValue AND Zielgruppe__c=:ZielgruppeValue AND Inaktiv__c=false)]; } return searchResult; } @AuraEnabled public static Map<String, String> getTypFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Typ__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } @AuraEnabled public static Map<String, String> getThemaFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Thema__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } @AuraEnabled public static Map<String, String> getZielgruppeFieldValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Mediathek__c.Zielgruppe__c.getDescribe(); List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pValues) { options.put(p.getValue(), p.getLabel()); } return options; } }