My project is working flawlessly, the only problem that I am having is that the search is case sensistive. It can search substrings just fine but if I type "Test", it ignores "test" as a valid result.
I am using pouchdb-find to make the search easier and more related to the cloudant search and limit/skip paramater for pagination.
I am using the ion-searchbar for the user to type the queried string.
Here is my controlers code's excerpt:
@Component({
selector: 'page-notas',
templateUrl: 'notas.html'
})
export class NotasPage {
notas: Array<Object> = [];
zone: any = new NgZone({ enableLongStackTrace: false });
db: any = new PouchDB('banco_de_dados.bd');
db_limit = 10;
pouch_query: object = {
selector: { data_emissao: { $gt: null } },
sort: [ {'data_emissao' : 'desc'} ],
limit: 10,
skip: 0,
};
constructor(
private scanner: BarcodeScanner,
private toastCtrl: ToastController,
private googleAnalytics: GoogleAnalytics,
public navCtrl: NavController,
public alertCtrl: AlertController,
public modalCtrl: ModalController
) {
this.notas = [];
}
//...
// unrelated code in here
//...
onInput($event:any) {
this.googleAnalytics.trackEvent('SearchBar', 'onInput', 'Event: ' + $event);
//Here is the query options, it's working, the only problem is that it's case sensitive
this.pouch_query = {
selector: {
data_emissao: { $gt: null },
descricao: { $regex: this.search_query }
},
sort: [ {'data_emissao' : 'desc'} ],
limit: 10,
skip: 0
};
// this function is a little bigger
// butit just makes the search and list it in a ion-list
this.refresh();
}
}
And here is the component code excerpt.
<!-- MORE UNRELATED CODE -->
<ion-searchbar
[(ngModel)]="search_query"
[showCancelButton]="shoulShowCancelButton"
(ionInput)="onInput($event)"
(ionCancel)="onCancel($event)">
</ion-searchbar>
<!-- MORE UNRELATED CODE -->